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
Kyriacos TheohariKyriacos Theohari 

Onclick JavaScript button to update datetime not working anymore

I have a button that when clicked returns a datetime and a user in a field. When this was setup it was working however it has now stopped working.

The following error message is now displayed:

A problem with the OnClick JavaScript for this button or link was encountered:

{faultcode:'soapenv:Client', faultstring:''NaN-NaN-NaNTNaN:NaN:NaN.NaN-NaN:NaN' is not a valid value for the type xsd:dateTime', }


This is the script used for the button:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

// identify the record
var a = new sforce.SObject("Account");
a.id = "{!Account.Id}";

// Get the user Info
var user = sforce.connection.getUserInfo();
// make the field change
a.Customer_Contacted_Date__c = new Date(Date.parse( '{!NOW()}'));
a.Contacted_By__c = user.userId; 

// save the change
sforce.connection.update([a]);

//refresh the page
window.location.reload();
v varaprasadv varaprasad
Hi Kyriacos.

a.Customer_Contacted_Date__c = new Date(Date.parse( '{!NOW()}'));
instead of that you can use 
a.Customer_Contacted_Date__c = system.today();

please let me know Customer_Contacted_Date__c is date field or DateTime field?

Thanks
Varaprasad


 
Kyriacos TheohariKyriacos Theohari
Hi I tried your variations and it didn't work, the field is a Date/Time field