• Travis Cooper 17
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I am curious if there is a difference between the permissions during the execution of a future method of an Apex Class versus a future method. I have a Customer Community Plus user with a profile that is not able to change their username unless I create the code to do so in a future method. Why is this? Is it possible to do this without a future method?
I need to allow the user to update their username in the portal. What permissions will the profile need in order to allow this change to occur?

At the moment I am getting a insufficient_access_on_cross_reference_entity error. In a trigger handler I am running the following code.

private void processUpdatedUserFields() {

        Id loggedUserId = UserInfo.getUserId();
        User currentUser = [SELECT Id, Name, Email FROM User WHERE Id =: loggedUserId];
        for (User newUser : (List<User>) Trigger.new) {
            User oldUser = (User) Trigger.oldMap.get(newUser.Id);
            if (loggedUserId == newUser.Id && newUser.Email != oldUser.Email) {
                system.debug(logginglevel.error, 'isUpdateable::: ' + Schema.sObjectType.User.fields.Username.isUpdateable());
                newUser.Username = newUser.Email;
            }
        }
        
    }

This is running beforeUpdate and used to run successfully.

Thank you.
I need to allow the user to update their username in the portal. What permissions will the profile need in order to allow this change to occur?

At the moment I am getting a insufficient_access_on_cross_reference_entity error. In a trigger handler I am running the following code.

private void processUpdatedUserFields() {

        Id loggedUserId = UserInfo.getUserId();
        User currentUser = [SELECT Id, Name, Email FROM User WHERE Id =: loggedUserId];
        for (User newUser : (List<User>) Trigger.new) {
            User oldUser = (User) Trigger.oldMap.get(newUser.Id);
            if (loggedUserId == newUser.Id && newUser.Email != oldUser.Email) {
                system.debug(logginglevel.error, 'isUpdateable::: ' + Schema.sObjectType.User.fields.Username.isUpdateable());
                newUser.Username = newUser.Email;
            }
        }
        
    }

This is running beforeUpdate and used to run successfully.

Thank you.