Skip to main content
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.
4 answers
  1. Jul 10, 2018, 1:58 PM
    Hi Travis,

    I think your commuity user profile  not able to access user object sothat you can not update this.

    for this solution you need set permisson Read and Write for user object in community user profile.

    if you need any assistanse, Please let me know!!

    Kindly mark my solution as the best answer if it helps you.

    Thanks

    Mukesh

     
0/9000