You need to sign in to do that
Don't have an account?
Bugude
Upsert User - DML not allowed on User
I am trying to create a user using Apex class for which I have written the following code.
<Previous Code>
User user = new User();
user.FirstName = String.valueOf(usr.FirstName);
user.LastName = String.valueOf(usr.LastName);
user.Username = String.valueOf(usr.UserName);
.
.
.
<set the values for all the required field>
Upsert user;
<Following Code>
When i am trying to save the class, I am facing the following error.
"DML not allowed on User".
Please suggest.
user.Username = String.valueOf(usr.UserName);
.
.
.
<set the values for all the required field>
Upsert user;
<Following Code>
When i am trying to save the class, I am facing the following error.
"DML not allowed on User".
Please suggest.
You is prolly hittin some license limit issues cuz u creatin' users in a dev org. Try settin the user IsActive flag to false in ur tests and that mite fix it.
look at this.. http://boards.developerforce.com/t5/Apex-Code-Development/DML-not-allowed-on-user-in-test-context/td-p/98393
did you try :
upser user <UniqueIdentifier OR ExternalID field>.
lik if my externalid filed is external__c the syntax upsert user external__c ;
Mohi,
I tried the external id option also but still got the same error.
I tried Insert user and Update user, surprisingly they are working fine but upsert user is not working.
Regards,
Lakshman