0

I am getting below error when clicking on Cls (custom detail button) on Custom object record.

faultcode:soapenv:Client,faultString:"6/3/2015" is not a valid value for type xsd:date

enter image description here

Below is the custom button code.

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

var newRecords = [];

var ib = new sforce.SObject("Disc__c"); 
ib.id = '{!Disc__c.Id}';
ib.Date_Closed__c = '{!TODAY()}';
alert(ib.Date_Closed__c);
ib.Status__c = 'Complete';
newRecords.push(ib);

result = sforce.connection.update(newRecords); 


window.location.reload();
0

I got it.Here is the solution

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

var newRecords = [];

var ib = new sforce.SObject("Disc__c"); 
ib.id = '{!Disc__c.Id}';
var today = new Date();
ib.Date_Closed__c = fixDate(today);
ib.Status__c = 'Complete';
newRecords.push(ib);

result = sforce.connection.update(newRecords); 


window.location.reload();



function fixTime(time){
    if(time < 10) {time = "0" + time};
    return time;
}

function fixDate(date){
  var Month = fixTime(date.getMonth() + 1);
  var Day = fixTime(date.getDate());
  var UTC = date.toUTCString();
  var Time = UTC.substring(UTC.indexOf(':')-2, UTC.indexOf(':')+6);
  var Minutes = fixTime(date.getMinutes());
  var Seconds = fixTime(date.getSeconds());
  return date.getFullYear() + "-" + Month + "-" + Day + "T" + Time;
}
| improve this answer | |
0

You could try with below snippet:

1. ib.Date_Closed__c = {!Today}

or, if you want to add days

2. ib.Date_Closed__c = new Date(start.setDate(start.getDate() + 30));

Thanks!

| improve this answer | |

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.