You need to sign in to do that
Don't have an account?
Kyriacos 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();
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();
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