You need to sign in to do that
Don't have an account?
Help with a custom javascript button
I'm trying to write a custom button to Execute JavaScript in a lead record that will:
- Send an email
- Check a box
- Add today's date to a field
- Display the lead record
So far I have the send the email working with:
location.replace('/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&rtype=00Q&retURL=%2F{!Lead.Id}&template_id=00Xi0000000h3Qh&p5=&save=1');
I tried configuring a second button to check a box with:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Lead");
c.id ="{!Lead.Id}";
c.00Ni00000046tXe_chkbox = true;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
It gives me an "Unexpected token ILLEGAL" error.
Can someone please help:
- Fix the checkbox issue
- Provide the JavaScript to change the date field to the current day
- Combine all 3 actions into 1 button
Thanks in advance,
John
I tried using the same code and I was able to check the checkbox, Can you use alert function to see are you getting the value. Is the field name correct?
c.00Ni00000046tXe_chkbox = true; ?
Thanks for the reply.
I did have the wrong field name. i think I have the correct one now?
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Lead");
c.id ="{!Lead.Id}";
c.00Ni00000046tXj = true;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();
I'm still getting the "Unexpected token ILLEGAL error.
I don't know how to use the alert function the way you're suggesting. Can you give me some guidance?
Thanks again,
John
c.00Ni00000046tXj = true;
00Ni00000046tXj is the 15 digit field character. Please follow the following steps.
setup>customize>lead> fields [ I am taking example of standard lead object, you need to choose your standard or custom object. custom object are under create].
Search for the field that you want to use and copy the API name mentioned against it. If it is a custom field then api name would be xyz__c.
alert functions are easy to use.
eg:
c.id ="{!Lead.Id}";
alert(c.id);
Thanks