function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arvind010Arvind010 

How to assign a profile to the user?

I want to assign a profile to the user.I used the following code:

User SPPuser = new User();
Profile prof = [Select id,Name from Profile where Name = 'Partner Admin User'];       
SPPuser.Profile = prof.id;
I am getting an error like:Illegal assignment from Id to SOBJECT:Profile

Please provide me the solution.
OzymandiasOzymandias
Try changing the last line to:

SPPuser.ProfileId = prof.id

As the error says, SPPuser.Profile expects an SObject, not an id.