[SalesForce] OnClick Javascript Ajax Toolkit, Custom button update a field

I have a custom object: Ticket__c

In that object I added a custom button, and I want to update an attribute of the object (Escalate__c) from false to true, I am not sure how to do this right now I have something like this:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var result = sforce.apex.execute("evticket__c" : true);
alert(result);
window.location.reload();

Thanks

Best Answer

Your JavaScript isn't quite right, but unless you've written a method for this, it'd be easier to update the record directly:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var record = new sforce.SObject("Ticket__c");
    record.Id = "{!Ticket__c.Id}";
    record.Escalate__c = true;
var result = sforce.connection.update([record]);
// check the result here
window.location.reload();
Related Topic