You need to sign in to do that
Don't have an account?
![aravind swaminathan aravind swaminathan](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
SObject row does not allow errors
Hello,
We are trying to update user profile information and we are using upsert method to do it.When we are trying to do so, some records got upadted succesfully but we got "System.FinalException : Sobject row does not allow errors" and error code is "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" AND Error Message is UserTrigger:execution of AfterUpdate.
class.user.BLogic.closeOpentasksforChampionUser: line 213,column 1
Can you please help us with this?what is causing it?
Thanks.
We are trying to update user profile information and we are using upsert method to do it.When we are trying to do so, some records got upadted succesfully but we got "System.FinalException : Sobject row does not allow errors" and error code is "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" AND Error Message is UserTrigger:execution of AfterUpdate.
class.user.BLogic.closeOpentasksforChampionUser: line 213,column 1
Can you please help us with this?what is causing it?
Thanks.
Please paste your code here, so that it will be easy to troubleshoot the issue.
Regards,
Mahesh
userFields[1] = makeElement("Alias", u.firstName.Substring(0, 1) + lastName);
userFields[2] = makeElement("CompanyName", u.companyName);
userFields[3] = makeElement("Department", u.department);
userFields[4] = makeElement("Division", u.division);
userFields[5] = makeElement("Email", u.email);
userFields[6] = makeElement("EmailEncodingKey", u.emailEncodingKey);
userFields[7] = makeElement("EmployeeNumber", u.employeeNumber);
userFields[8] = makeElement("Fax", u.fax);
userFields[9] = makeElement("FederationIdentifier", u.federationIdentifier);
userFields[10] = makeElement("FirstName", u.firstName);
userFields[11] = makeElement("LanguageLocaleKey", u.languageLocaleKey);
userFields[12] = makeElement("LastName", u.lastName);
userFields[13] = makeElement("LocaleSidKey", u.localeSidKey);
userFields[14] = makeElement("MobilePhone", u.mobilePhone);
userFields[15] = makeElement("CommunityNickname", u.firstName.Substring(0, 1) + "_" + u.lastName);
userFields[16] = makeElement("Phone", u.phone);
userFields[17] = makeElement("TimeZoneSidKey", "America/Chicago");
userFields[18] = makeElement("Username", u.email);
userFields[19] = makeElement("EmployeeNumber__c", u.employeeNumber);
userFields[20] = makeElement("Title", u.title);
userFields[21] = makeElement("ProfileId", "xyz");
userFields[22] = makeElement("ManagerId", u.manager);
newUser.type = "User";
newUser.Any = userFields;
userList[x] = newUser;
UpsertResult[] results = binding.upsert("EmployeeNumber__c", userList);
for (int j = 0; j < results.Length; j++)
{
if (j == x)
{
if (results[j].success)
{
successes++;
else
{
errors++;
for (int i = 0; i < results[j].errors.Length; i++)
{
Error err = results[j].errors[i];
Console.WriteLine("Errors were found on item " + j.ToString());
Console.WriteLine("Error code is: " + err.statusCode.ToString());
Console.WriteLine("Error message: " + err.message);
}
}
}
}
Also, I am trying to use upsert to update a record and i get this message for some records-"Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). ".
It works for certain users but not all?The empoyee number, email address match but i get this exception.
Another thing is when i try to insert new user, i get an error asking to "Business unit must be defined by user".I am already passing company name,division,district etc.
I am trying to update the profile information.So, even if username exists, it should have updated the record right when i use Upsert.Why is it trying to insert and giving me "Duplicate Username.<br>The username already exists in this or another Salesforce organization. Usernames must be unique across all Salesforce organizations. To resolve, use a different username (it doesn't need to match the user's email address). ".Is it looking at UserName field only or is it looking at any other fields to determine whether it is a insert or update?Is it not supposed to insert when username does not exist and update when username exists?
The problem will be in your UserTrigger in the closeOpentasksforChampionUser method on line 213. There is likely a Database DML operation occuring that is attempting to update a User in the current trigger context.
An after update trigger can't update the current record by default. Otherwise it would be too easy to create a recursive trigger.
How you fix this will really depend on what the triggered code is doing. You might be able to use a static member to prevent the recursion.
Yes you need to contact Salesforce Team to troubleshoot the issue.
Provide the above error message to your Salesforce Team and they can able to identify the root cause and provide the solution.
Please do let me know if it helps you.
Regards,
Mahesh