You need to sign in to do that
Don't have an account?
jingyuan xie 6
help me out about custom date stamp button
Hi ,I'm trying to create a custom button in leads detail page that when clicked will populate a custom field called attampt date 1 with the current date. The attempt date 1 field is set up as a date field,and JS like this,but when clicked the button,it returned an error message like "A problem with the OnClick JavaScript for this button or link was encountered:expected token="
Can anyone help to find out the reason , thanks!!!
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("lead");
c.id ="{!Lead.Id}";
c.{!Lead.attempt1_date__c} = new Date().toISOString();
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
Can anyone help to find out the reason , thanks!!!
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("lead");
c.id ="{!Lead.Id}";
c.{!Lead.attempt1_date__c} = new Date().toISOString();
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
Try This:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var c = new sforce.SObject("Lead");
c.id ="{!Lead.Id}";
c.attempt1_date__c = new Date().toISOString();
result = sforce.connection.update([c]);
window.location.reload();
Thanks,
Let the Force be with you!
Please mark this as best answer if it helps you.
All Answers
Try This:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var c = new sforce.SObject("Lead");
c.id ="{!Lead.Id}";
c.attempt1_date__c = new Date().toISOString();
result = sforce.connection.update([c]);
window.location.reload();
Thanks,
Let the Force be with you!
Please mark this as best answer if it helps you.
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("lead");
c.id ="{!Lead.Id}";
c.attempt1_date__c = new Date();
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
The issue in your code was with this,you should have just given object.field.
c.{!Lead.attempt1_date__c}
Thanks,
Have a good day ahead!
Let the Force be with you!