You need to sign in to do that
Don't have an account?
PCRecycler
Custom Button for Checkbox Field
I'm trying to create a custom button on a custom object called Job that when used would mark a custom check box called Job_Item_Call_Out true.
Here is the code that i have:
When the button is executed i'm getting an error
A problem with the OnClick JavaScript for this button or link was encountered: Unexpected number '.0' |
Please check the below code. It should work and will resolve the issue.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var myJob = new sforce.SObject("Job__c");
myJob.Id = "{!Job__c.Id}";
myJob.Job_Item_Call_Out__c = "true";
var result = sforce.connection.update([myJob]);
window.location.reload();
Object Name = Job__c
Field Name = Job_Item_Call_Out__c
Thanks & Best Regards.
All Answers
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var a = new sforce.SObject("Job");
a.Id = "{!Job__c.Id}";
a.Job__c.Job_Item_Call_Out__c = true;
sforce.connection.update([a]);
location.reload(true);
remove the merge field syntax over there
Please look at the below code for custom button javascript.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
var myJob = new sforce.SObject("Job__c");
myJob.Id = "{!Job__c.Id}";
myJob.Job__c.Job_Item_Call_Out__c = "true";
var result = sforce.connection.update([myJob]);
It should resolve your problem. Please give me feedback if you have any query.
Thanks
kiran_mutturu,
This didn't work. Got the following messgae "Can not set property 'Job_Item_Call_Out__c' of undefined.
any suggestions?
The object is Job__C and the field is Job_Item_Call_Out__c and we are trying to set the value to true.
It seems very simple so i can't see why it wouldn't work. This is being executed from a
Please check the below code. It should work and will resolve the issue.
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var myJob = new sforce.SObject("Job__c");
myJob.Id = "{!Job__c.Id}";
myJob.Job_Item_Call_Out__c = "true";
var result = sforce.connection.update([myJob]);
window.location.reload();
Object Name = Job__c
Field Name = Job_Item_Call_Out__c
Thanks & Best Regards.