My requirement is when a user logged into customer portal using credentials-profile has to be changed when a action is called on button-click. At the time of login -profile is say 'abc'. I have called a future method onclick of a button to change the profile to say 'xyz'. I am able to change the useremail but not the profileID,it is showing the following error: FIELD_INTEGRITY_EXCEPTION, Cannot change profile for current user: Profile ID
My future method is as follows:
@future
public static void updateuserAFL(id userId,id profileid){
User tempUser = [select id,name,Email,Username,Profileid from user where id=:userId ];
tempUser.ProfileId=profileid;
tempUser.Email='test@mphasis.com';
update tempUser;
}
Can anyone please help me how to change the profie of the logged in user..