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.
 
Newbie__SalesforceNewbie__Salesforce
Hi SFDC Guest,

Try this 

/apex/vfpage?oliId={!OpportunityLineItem.Id}&oppDate={!Opportunity.customDate__c}
Niraj Kr SinghNiraj Kr Singh
Hi,

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.

Thanks
Niraj
 
Sampath SuranjiSampath Suranji
Hi,
It seems you have a space between the query string,
url should be like this,
/apex/vfpage?oliId={!OpportunityLineItem.Id}&&oppDate={!Opportunity.customDate__c}

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

regards
devedeve
Hi,

This URL is to be something like this 
/apex/vfpage?oliId={!OpportunityLineItem.Id}&oppDate={!Opportunity.customDate__c}