You need to sign in to do that
Don't have an account?

Mixing of EntityObjects with different UddInfos
Please need help with how to resolve this error:
Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, java.lang.IllegalStateException Programmer Error: you cannot mix EntityObjects with different UddInfos within one transaction: id = null: [] stack Class.MM_AccountSharingTest.testAccountSharingTrigger: line 74, column 1
Here is my code snippet (line 74 in red):
static testMethod void testAccountSharingTrigger() {
Id adminProfile = [Select Id From Profile Where Name = 'System Administrator' Limit 1].id;
Id dmeProfile = [Select Id From Profile Where Name = 'DME Portal User' Limit 1].id;
// Select admin user.
Id roleId = [SELECT Id FROM UserRole where Name = 'System Administrator' ].id;
Id adminUser = [SELECT Id FROM User WHERE IsActive = true and UserRoleId = :roleId LIMIT 1].id;
Id type1Id = [Select id from RecordType where SobjectType = 'Account' and Name = 'Implanting Center'].id;
Id type2Id = [Select id from RecordType where SobjectType = 'Account' and Name = 'DME Center'].id;
//create a new Sys Admin user
User sysAdmin = new User();
sysAdmin.Username = 'sys.admin_testAccountSharingTrigger@test.com';
sysAdmin.Email = 'admin.ser@test.com';
sysAdmin.Alias = 'admin';
sysAdmin.CommunityNickname = 'admin';
sysAdmin.TimeZoneSidKey = 'America/Los_Angeles';
sysAdmin.LocaleSidKey = 'en_US';
sysAdmin.EmailEncodingKey = 'UTF-8';
sysAdmin.ProfileId = adminProfile;
sysAdmin.LanguageLocaleKey = 'en_US';
sysAdmin.FirstName = 'Sys';
sysAdmin.LastName = 'Admin';
insert sysAdmin; ------- this is line 74
// Create new account.
Account implantCtr = new Account();
implantCtr.Name = 'Implanting Center Account';
implantCtr.BillingCity = 'San Diego';
implantCtr.BillingPostalCode = '92121';
implantCtr.RecordTypeId = type1Id;
implantCtr.OwnerId = adminUser;
insert implantCtr;
}
Thanks,
-ST
Can you please try commenting the line :
sysAdmin.ProfileId = adminProfile;