function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC GuestSFDC Guest 

How to pass date as a parameter from custom button url to constructor

Hi, I have created a detail custom button of url type and passing Opportunity Date as shown below.

/apex/vfpage?oliId={!OpportunityLineItem.Id} && oppDate={!Opportunity.customDate__c}

And in apex constructor i am receiving the custom date value as below.

customDate = Date.valueOf(ApexPages.currentPage().getParameters().get('oppDate'));
But I am receiving error as
"Argument cannot be null. An unexpected error has occurred. Your development organization has been notified. "

How to pass the oppDate from url to constructor.
Hi SFDC Guest,

Try this 

Niraj Kr SinghNiraj Kr Singh

In url u have used "&&", It should be "&". Like this:
/apex/vfpage?oliId={!OpportunityLineItem.Id} & oppDate={!Opportunity.customDate__c}
try this.

If it will not work then convert Date to String and pass in url. And while receving again convert to Date.

Sampath SuranjiSampath Suranji
It seems you have a space between the query string,
url should be like this,

and inside the controller try like below,
string strDate= ApexPages.currentPage().getParameters().get('oppDate');
            date customDate = Date.parse(strDate);


This URL is to be something like this