+ Start a Discussion
babaKhanbabaKhan 

ERROR MESSAGE: Argument 2 cannot be null Error is in expression '{!methodName}' in component <apex:page> in page namespace:className: External entry point

Hi,

I'm facing a problem regarding PageReference object. When I use the following code in Scratch Org and push the Package to client Org then all works as expected:
     PageReference pdf = Page.pageName;
     pdf.getParameters().put('id',si.id);    
     pdf.setRedirect(true);     
     Blob b  = pdf.getContent();     //it works and blob content created to insert the document record
 
However, updating the code like following only works in Scratch Org but failed when moving Package to client org.
     PageReference pdf = new PageReference('/apex/'+si.Invoice_Template__r.Visualforce_Page__c);
     pdf.getParameters().put('id',si.id);    
     pdf.setRedirect(true);     
     Blob b = pdf.getContent();     //this fails to execute and the following error thrown
 
ERROR MESSAGE: Argument 2 cannot be null Error is in expression '{!methodName}' in component <apex:page> in page namespace:className: External entry point
 
Looking forward to get some help on this please. Thanks
Wajeed KhanWajeed Khan
Hello ,

You are not entering any value to that particular field , so when it tries to fetch , it will throw error, Use exception handling in your controller

Thanks
babaKhanbabaKhan
Hi Wajeed,

Thanks for reply. Sorry couldn't describe it first that this is the partial code and the value is assigned to the field. Also, debug log is showing the value.

But, my wondering is that, this works in Scratch Org, but failed in the Client Org after packaging.

An ideas/workaround please?