2

I need to update a datetime field with current date time in VF page using JavaScript.Currently my code is like this :

        var newRecords = [];
        var a = new sforce.SObject("myObj__c");
        a.id ="{!myObj.Id}";
        var today = new Date();
        a.Last_Time_Executed__c = sforce.internal.dateTimeToString(today);
        newRecords.push(a);
        result = sforce.connection.update(newRecords);

But it shows this error:

{faultcode:'soapenv:Client', faultstring:''2013-11-27T13:04:46.539+05.5:30' is not a valid value for the type xsd:dateTime', }

3

This worked:

        var newRecords = [];
        var a = new sforce.SObject("MyObj__c");
        a.id ="{!SOQL_Report__c.Id}";
        a.Last_Time_Executed__c = new Date().toISOString();
        newRecords.push(a);
        result = sforce.connection.update(newRecords);

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.