After the migration of our one of the sandbox and PROD org to HYPERFORCE. Test classes started failing majorly due to some person account query. this is still working without any issue in non hyperforce migrated org.
Error i am receiving during the deployment is mentioned below -
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: 0121a0000005voBAAQ: [RecordTypeId]Stack Trace: Class.TestDataInitiator.insertTestPersonAccounts: line 50, column 1 Class.AccessSharingControl_Manager_Test.AccessSharingControl_ManagerTestMethod: line 10, column 1
Test Class which is failing after migration-
@isTestpublic class TestDataInitiator{ public static Lead insertTestLead() { Lead testLead = new Lead(); testLead.Date_Of_Birth__c = Date.today().addYears(- 75); testLead.PostalCode = '02186'; testLead.FirstName = 'test'; testLead.LastName = 'Lead'; testLead.LeadSource = 'Other/Null/Blank'; testLead.Status = 'Open'; insert testLead; return testLead; } public static Account insertTestPersonAccounts(){ RecordType recType = [select id from RecordType where sObjectType = 'Account' and isPersonType = true LIMIT 1]; Account testAccount = new Account(); testAccount.firstName = 'Test first Name'; testAccount.lastName = 'Test Last Name'; testAccount.Salutation='Mr'; testAccount.MiddleName='MiddlName'; testAccount.Suffix='Suffix'; testAccount.PersonEmail='hphctest@test.com'; testAccount.PersonBirthdate = Date.newInstance(1960, 02, 17); // testAccount.LDAP_Username__pc = 'hphc@tst.com'; testAccount.RecordTypeId = recType.id; testAccount.vlocity_ins__SocialSecurityNumber__pc = '237-65-0345';//added by ashok testAccount.Tobacco_Use__c='Yes'; testAccount.BillingCountry = 'US'; testAccount.Billingpostalcode = '02186'; testAccount.BillingState = 'MA'; testAccount.ShippingStreet = '108 CHURCH RD' ; testAccount.Shippingcity = 'MILL RIVER' ; testAccount.ShippingState = 'MA' ;//Changed by ashok as per new validation rule for shipping state testAccount.ShippingCountry = '' ; testAccount.ShippingPostalCode = '01244' ; testAccount.PersonOtherCountry = 'US'; testAccount.PersonOtherPostalCode = '02186'; testAccount.PersonOtherState = 'MA'; testAccount.PersonOtherStreet = '108 CHURCH RD' ; testAccount.PersonOtherCity = 'MILTON' ; testAccount.PersonMailingState = 'MA' ; testAccount.PersonMailingStreet = '108 CHURCH RD'; testAccount.PersonMailingCountry = 'US'; testAccount.PersonMailingCity = 'MILTON'; testAccount.PersonMailingPostalCode = '02186' ; insert testAccount; return testAccount; }
#Salesforce Developer
3 respuestas
Please check any licenses or permissions messed up after the migration.
One of our sandbox licenses was deactivated/deleted after migration, and nothing worked. I clicked "Match Production Licenses" to restore, and then it started working again.