Hi @Mohammad Qasim ,
This is not possible to retrieve all items while using Read items that were created by the user settings. If you want to use Jsom grant permission. You must remove Read items that were created by the user settings. Then you can refer to the following code
function UpdatePermissionLevel() {
// You can optionally specify the Site URL here to get the context
// If you don't specify the URL, the method will get the context of the current site
// var clientContext = new SP.ClientContext("http://MyServer/sites/SiteCollection");
var clientContext = new SP.ClientContext();
var oRoleDefinition = clientContext.get_web().get_roleDefinitions().getByName("Custom Role");
// BasePermissions Object
var oBasePermissions = new SP.BasePermissions();
oBasePermissions.set(SP.PermissionKind.viewListItems);
// set role definition permission level
oRoleDefinition.set_basePermissions(oBasePermissions);
// Set Role definition description
oRoleDefinition.set_description('Updated Custom Role Description');
// Update role definition
oRoleDefinition.update();
// Execute the query to the server.
clientContext.executeQueryAsync(onsuccess, onfailed);
}
function onsuccess() {
console.log('Success');
}
function onfailed(sender, args) {
console.log('Failed' + args.get_message() + '\n' + args.get_stackTrace());
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.