I am updating the record in the javascript while clicking on custom button. I have custom date/time field Approved_Date__c. I need to update that fields also using javascript. How can I assign current date/time to Approved_Date__c field?

I tried like


but i am getting:

A problem with onclick javascript for this button or link was encountered. Now not defined.

I tried like this also

jpt.Approved_Date__c=new Date().toLocaleString();

it's showing as:

{faultcode:'soapenvClient', faultstring:''3/21/2016, 3:05:33 PM' is notavalid value for the type xsd:dateTime',}

  • use a apex:inputhidden and set the value of that inputhidden Mar 21 '16 at 10:25
  • I am not using any vf page. I am updating this in custom button in standard page. Mar 21 '16 at 11:02

I got solution for this. I tried like this..

jpt.Approved_Date__c=new Date().toISOString();

I believe you are in the right direction. The only thing I see missing is the {! expression }.

I believe the first approach will work for you.

set("Approved_Date__c",{! NOW() });

  • Hi Manjit, that's also not worked for me. Mar 21 '16 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.