+ Start a Discussion
StaciStaci 

Pre-populating current date/time with URL

I have this:

PageReference retPage = new PageReference('/' + changeID + '/e?00Na000000BA4Ip=Rejected&00Na000000BA4IU=True&00Na000000BA4IW=UserInfo.getName()&00Na000000BA4IV=');

 This needs to equal the current date and time.  How do I accomplish that?

00Na000000BA4IV=
Best Answer chosen by Admin (Salesforce Developers) 
levaleva


How about formating the result as string and  calling html escape method on the result 

 

DateTime.now().format().escapeHtml4();

 

There are other escape methods you could try if it does not work - escapeEcmaScript, check the docs

All Answers

ryanjuptonryanjupton

You could try using System.now() or DateTime.noe(). Both with generate the current datetime. Are you looking for something more detailed?

StaciStaci

Hi Ryan

 

That's what I was trying to use and both when they try to populate error and says invalid date and time and you see System.now() in the box.  I've tried {} around it, ' ' and " " around it.  All act the same.

Sandeep001Sandeep001

Doesn't this work:

 

PageReference retPage = new PageReference('/' + changeID + '/e?00Na000000BA4Ip=Rejected&00Na000000BA4IU=True&00Na000000BA4IV='+datetime.now());

levaleva


How about formating the result as string and  calling html escape method on the result 

 

DateTime.now().format().escapeHtml4();

 

There are other escape methods you could try if it does not work - escapeEcmaScript, check the docs

This was selected as the best answer
StaciStaci

thanks leva, that worked