You need to sign in to do that
Don't have an account?
SFine
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id
I was correcting some mistakes when I began to receive this error on something that previously worked and I'm not sure why it's not working now. I've narrowed it down to this section of code:
List<Contract_Line_Item__c> current_cls=[select Id, hasCPI__c, Name, Product__c, Net_Price__c, Quantity__c, Maintenance_Amount__c, isCheckbox__c from Contract_Line_Item__c where Contract__c=:current.Id]; List<Contract_Line_Item__c> cls=new List<Contract_Line_Item__c>(); boolean cpiX; for(Contract_Line_Item__c cli:current_cls){ if(cli.Maintenance_Amount__c > 0) { cpiX=false; Contract_Line_Item__c cl = cli.clone(false, true); Contract_Line_Item__c cpi = cli.clone(false, true); cl.Net_Price__c=0; cl.Services_Amount__c=0; if(!cli.isCheckbox__c) { cpi.Net_Price__c=0; cl.Contract__c=c.Id; cl.Net_Price__c=0; if(current.CIPIX_Increase__c=='Yes' && current.CPI_Increase_Percent__c!=null){ if(cli.hasCPI__c) cl.Maintenance_Amount__c*=1+(current.CPI_Increase_Percent__c/100); cl.hasCpi__c=true; cpi.hasCPI__c=true; cpi.Contract__c=c.Id; cpi.Maintenance_Amount__c=cl.Maintenance_Amount__c*(current.CPI_Increase_Percent__c/100); cpi.Name=cli.Name; cpi.isCheckbox__c=true; cpiX=true; } cls.add(cl); if(cpiX) cls.add(cpi); a=new Asset(); a.AccountId = c.AccountId; a.Product2Id=cli.Product__c; a.Name=cli.Name + ' - Asset'; a.ContactId=Cont; if(c.startDate!=null){ a.installDate=c.StartDate; date enddate=c.StartDate.addMonths(12).addDays(-1); a.UsageEndDate=enddate; } insert a;} else{ delete cli;} } } insert cls;
And when I comment out the "If.isCheckBox__c) sections, I get a 'de-referencing a null object error'. Any advice?
Silly question, but do you have with sharing enabled?
All Answers
Silly question, but do you have with sharing enabled?
Doh! What do you know? That was it.
I narrowed it further to Asset creation and further more to the startdate section, but once you put 'with sharing' at the class header. It worked fine. Thanks