I receive the following error message when trying to upload my code to production
System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Service Record Type: this ID value isn't valid for the user: 0128E0000004m8bQAA: [RecordTypeId] Stack Trace: Class.TEST_OpOwnerConvertedServiceNotif.TEST_OpOwnerConvertedServiceNotif: line 16, column 1
Below is my test class, what do I need to change, for this to upload to production?
@istest private class TEST_OpOwnerConvertedServiceNotif
{
static testMethod void TEST_OpOwnerConvertedServiceNotif ()
{
Account acc = new Account(Name = 'Test Account');
insert acc;
ID pricebookId = Test.getStandardPricebookId();
RecordType RecType = [Select Name, Id From RecordType
where sObjectType='Product2' and DeveloperName = 'Unavailable_R_D_Service'];
User U = [Select Id FROM User WHERE Email = 'glenn.daly@jisc.ac.uk'];
Product2 prd1 = new Product2 (Name = 'Test Product Entry 1', Description = 'Test Product Entry 1',
productCode = 'ABC', isActive = false,
RecordTypeId = RecType.id,
R_D_Service_Owner__c = u.Id,
Convert_to_Service_Catalogue_Initiated__c = TRUE,
Convert_to_Service_Catalogue_Emailed__c = FALSE);
insert prd1;
PricebookEntry pbe1 = new PricebookEntry
(Product2ID=prd1.id, Pricebook2ID = pricebookId,UnitPrice=0, isActive=true);
insert pbe1;
Opportunity opp1 = new Opportunity (Name='Opp1', StageName='Proposal Accepted', CloseDate=Date.today(),
Pricebook2Id = pbe1.Pricebook2Id, AccountId = acc.id);
insert opp1;
OpportunityLineItem lineItem1 = new OpportunityLineItem
(OpportunityID = opp1.id, PriceBookEntryID = pbe1.id, quantity=1, totalprice=0);
insert lineItem1;
Test.startTest();
OpOwnerConvertedServiceNotif sobj = new OpOwnerConvertedServiceNotif();
system.schedule('Scheduable_Class', '0 0 23 * * ?', sobj);
Test.stopTest();
}
}