You need to sign in to do that
Don't have an account?
Gaither Simmons
Test Class unable to insert opportunity
In my test class I need to create an opportunity to test against.
//Create Opportunity
// set up opp and Verify that the results are as expected.
RecordType SigSales = [select Id from RecordType where Name = 'Sigma Sales' and SobjectType = 'Opportunity'];
String opportunityName = 'My TEST Opportunity';
Opportunity opp1 = new Opportunity(
//AccountId=testAccount.Id,
Name=opportunityName,
StageName='Idea',
CloseDate=Date.today(),
RecordType=SigSales
);
insert opp1;
When I run the test I get the following error:
11:12:43.788 (12788478666)|VF_PAGE_MESSAGE|You can't create an Opportunity Split for a user unless they're part of the opportunity team.
11:12:43.788 (12788578660)|EXCEPTION_THROWN|[77]|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
11:12:43.789 (12789451592)|HEAP_ALLOCATE|[77]|Bytes:196
11:12:43.797 (12797690786)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
Class.TestAddSAFromAccounttoOpp.myUnitTest: line 77, column 1
11:12:43.797 (12797713236)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
I am not attempting to create any splits. Not sure what is going on here.
Thanks!
Gaither
//Create Opportunity
// set up opp and Verify that the results are as expected.
RecordType SigSales = [select Id from RecordType where Name = 'Sigma Sales' and SobjectType = 'Opportunity'];
String opportunityName = 'My TEST Opportunity';
Opportunity opp1 = new Opportunity(
//AccountId=testAccount.Id,
Name=opportunityName,
StageName='Idea',
CloseDate=Date.today(),
RecordType=SigSales
);
insert opp1;
When I run the test I get the following error:
11:12:43.788 (12788478666)|VF_PAGE_MESSAGE|You can't create an Opportunity Split for a user unless they're part of the opportunity team.
11:12:43.788 (12788578660)|EXCEPTION_THROWN|[77]|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
11:12:43.789 (12789451592)|HEAP_ALLOCATE|[77]|Bytes:196
11:12:43.797 (12797690786)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
Class.TestAddSAFromAccounttoOpp.myUnitTest: line 77, column 1
11:12:43.797 (12797713236)|FATAL_ERROR|System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, You can't create an Opportunity Split for a user unless they're part of the opportunity team.: [SplitOwnerId]
I am not attempting to create any splits. Not sure what is going on here.
Thanks!
Gaither
Today similar kind of issue got fixed by adding the OwnerId field while inserting the Opportunity record.
Regards,
Mahesh