You need to sign in to do that
Don't have an account?
Mick Mu
URL Encode
Hi all,
I have a custom button on Opportunity which calls a VF Page which passes a number of parameters to a apex class. in the class i create a url set various text fiels and redirect the user to another object screen and the fields are pre populated. This works great for text and currency.
The problem i have is Dates it seems that in the url dates are coming out as 2010-10-25. To put text into the url im using:
String AccName = EncodingUtil.urlEncode(opportunity.Account.Name, 'UTF-8');
Does anyone know if there's anything similar for Dates?
Thanks
Try
opportunity.CloseDate.format()
Regards,
Hengky
All Answers
Hi,
2010-10-25 is a valid URL actually.
Anyway, if you construct the URL using the getParameters method from PageReference class, the URL encoding will be handled automatically.
Regards,
Hengky
Hi thanks for your reply, its not that the url is wrong its when i try and assign it to a date field on the object, this is how im currently doing it...
PageReference pageRef = new PageReference('/a0U/e?CF00NM0000000fO6D=' + oppName + '&CF00NM0000000fO6D_lkid=' + opportunity.Id +
'&CF00NM0000000fO6P='+ AccName + '&CF00NM0000000fO6P_lkid=' + opportunity.AccountId +
'&CF00NM0000000fO6h='+ OppOwner + '&CF00NM0000000fO6h_lkid=' + opportunity.OwnerId +
'&00NM0000000fO7C='+ opportunity.Total_Margin__c + '&00NM0000000fO7D=' + opportunity.Total_Revenue__c +
'&00NM0000000fO6m=' + opportunity.PS_Revenue__c + '&00NM0000000fO6l=' + opportunity.PS_Margin__c +
'&00NM0000000fO6U=' + opportunity.CS_Revenue__c + '&00NM0000000fO6T=' + opportunity.CS_Margin__c +
'&00NM0000000fO7A=' + opportunity.System_Revenue__c + '&00NM0000000fO79=' opportunity.System_Margin__c + '&00NM0000000fO6i=' + opportunity.CloseDate
);
This works fine for all other fields, but the date is coming through as 2010-10-25 when it needs to be 25/10/2010
Am I missing something stupid here?
Thanks
Try
opportunity.CloseDate.format()
Regards,
Hengky
AH! thats got it! cheers for your help!