Note that there are some explanatory texts on larger screens.

plurals
  1. POSystem.NullPointerException: Attempt to de-reference a null object
    primarykey
    data
    text
    <p>I have to create a new object and copy all the fields form the old one to a new one and it is a child to opportunity.</p> <p>The copyfields is a method that copies the fields from one object to another and the function call line in the cloning method is the line where I am getting the exception.</p> <pre><code>public LQAgreementCloneCtrl(ApexPages.StandardController controller) { lqa = [Select off1stdate__c, hosp1stdate__c, Zip_Code_New__c, X66_Contract__c,WAWF__c,,AccountRevenue__c From LQ_Agreement__c Where id=:ApexPages.currentPage().getParameters().get('id')]; o = [Select of_Hospitals__c, X8_Gal__c, X4_Gal__c, X3mo_Avg_LBS_stop__c, X3_Gal__c, X2_Gal__c, X1st_Pick_Up_Date__c, X17_Gal__c, X12_month_Actual_Stops__c, X12_mo_Avg_Rev__c, Waste_Destruction_Date__c, WS_Other__c, Vision_Match__c, Value_analysis_committee__c, AR_FuelFee__c, AR_FixerFee__c, AR_EnergyFee__c, APPROVALS__c,RecordType.Name From Opportunity WHERE Id=:lqa.Opportunity__c]; } public PageReference cloning(){ if(lqa.Status__c=='Deal Approved'){ //oclone=o; //oclone.id=null; oclone=o.clone(); insert oclone; System.debug('Oclone&gt;&gt;&gt;&gt;&gt;&gt;&gt;'+oclone); LQ_Agreement__c lqaclone=new LQ_agreement__c(); //lqaclone=new LQ_Agreement__c(); lqaclone.Opportunity__c=oclone.Id; System.debug('LQAClone&gt;&gt;&gt;&gt;&gt;'+lqaclone); lqaclone=copyfields(lqaclone,lqa); oclone.Name=o.Name+'-Amended'; //Checking the Record type of the original Opportunity to create the new cloned Opp with RecordType of same waste stream + amendment added if(o.RecordType.Name=='LQ Bio/SMS Renewal'|| o.RecordType.Name=='LQ Bio/SMS New Business' ) oclone.RecordType.Name='LQ BIO/SMS Amendment'; if(o.RecordType.Name=='LQ Haz Waste New Business'|| o.RecordType.Name=='LQ Haz Waste Renewal' ) oclone.RecordType.Name='LQ Haz Waste Amendment'; if(o.RecordType.Name=='LQ RMW New Business'|| o.RecordType.Name=='LQ RMW Renewal' ) oclone.RecordType.Name='LQ RMW Amendment'; if(o.RecordType.Name=='LQ Rx/Pharma New Business'|| o.RecordType.Name=='LQ Rx/Pharma Renewal' ) oclone.RecordType.Name='LQ Rx/Pharma Amendment'; //Checking the Record type of the original LQ Agreement to create the new cloned LQA with RecordType + amendment added if(lqa.RecordType.Name=='LQ Existing Agreement' || lqa.RecordType.Name=='LQ New Agreement' ) lqaclone.RecordType.Name='LQ New Agreement – Amendment'; if(lqa.RecordType.Name=='LQ Existing Agreement GPO' || lqa.RecordType.Name=='LQ New Agreement GPO' ) lqaclone.RecordType.Name='LQ New Agreement GPO – Amendment'; insert lqaclone; update oclone; p=new ApexPages.StandardController(lqaclone).view(); } else{ System.debug('Inside Else statement'); p=new ApexPages.StandardController(lqa).view(); } return p; } public LQ_Agreement__c copyfields(LQ_Agreement__c lqaclone1,LQ_Agreement__c lqa1){ lqaclone1.Approved_By_RSD__c=lqa1.Approved_By_RSD__c; lqaclone1.ApprovedByBrent__c=lqa1.ApprovedByBrent__c; lqaclone1.ApprovedByJIM__c=lqa1.ApprovedByJIM__c; lqaclone1.ApprovedByVP__c=lqa1.ApprovedByVP__c; } </code></pre> <p><strong>I am getting the exception at the function call to copyfields. The exception I get is Attempt to de-reference null object. Copy fields is a big function. I just gave a few lines</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload