You need to sign in to do that
Don't have an account?
Pallav
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY.. Need help !!
Hi All,
I am writting a unit testing method for my apex trigger and when running the following piece of code in the apex class I get the error message INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY while creating the "OpportunityLineItemSchedule". I have tried putting the "OpportunityLineItemId" hard coded then also it is showing the same error message. I cannot re move this as this is a required field.
public class testCodeCoverage
{
static testMethod void myTest()
{
OpportunityLineItem acccobj = new OpportunityLineItem(OpportunityId = 'AAAAAAAAAA', Description='This is a test descriptiion',Quantity=3,UnitPrice=5000,PricebookEntryId='11111');
insert acccobj;
OpportunityLineItemSchedule acccobj1 = new OpportunityLineItemSchedule(OpportunityLineItemId=acccobj.Id,Description='This is a test description',Revenue=10000,ScheduleDate=Date.newInstance(2008,02,02),Quantity=2,Type='both');
insert acccobj1;
}
}
Thanks in anticipation of your kind and helpful response.
thanks and regards
pallav
I am writting a unit testing method for my apex trigger and when running the following piece of code in the apex class I get the error message INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY while creating the "OpportunityLineItemSchedule". I have tried putting the "OpportunityLineItemId" hard coded then also it is showing the same error message. I cannot re move this as this is a required field.
public class testCodeCoverage
{
static testMethod void myTest()
{
OpportunityLineItem acccobj = new OpportunityLineItem(OpportunityId = 'AAAAAAAAAA', Description='This is a test descriptiion',Quantity=3,UnitPrice=5000,PricebookEntryId='11111');
insert acccobj;
OpportunityLineItemSchedule acccobj1 = new OpportunityLineItemSchedule(OpportunityLineItemId=acccobj.Id,Description='This is a test description',Revenue=10000,ScheduleDate=Date.newInstance(2008,02,02),Quantity=2,Type='both');
insert acccobj1;
}
}
Thanks in anticipation of your kind and helpful response.
thanks and regards
pallav
I think the issues are; you are trying to update an SObject but calling insert, and you only need to use Id not OpportunityLineItemId=...
Your code:
I am not sure becuase the error really doesn't tell you much, but what you are doing might cause this error.
There is nothing "wrong" with your code other then those two things.
Change your code to this:
Message Edited by mikef on 02-08-2008 02:55 PM
All Answers
I think the issues are; you are trying to update an SObject but calling insert, and you only need to use Id not OpportunityLineItemId=...
Your code:
I am not sure becuase the error really doesn't tell you much, but what you are doing might cause this error.
There is nothing "wrong" with your code other then those two things.
Change your code to this:
Message Edited by mikef on 02-08-2008 02:55 PM
Thanks a lot for replying... your advice really remoevd the error message that was comming... I really appriciate your help.
regards
pallav
Hi mikef,
I have coded my Testclass, as you mentioned here in the blog, but I really don't understand, why I should use "update" instead of insert for the opportuntiylineitemschedule.
updating theSchedule, that is not inserted before, cause a DmlException.
inserting theSchedule, cause a DmlException as mentioned in the subject line "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY"
any hints would be wonderful