I am trying to mark a checkbox via a javascript button, i.e. update it as true. The checkbox is a field (Precisa_Cota_o_Frete__c) in the opportunity, but I want the button to work from the quote detail page. Here is the code I've got so far, but I am getting an error message from Salesforce:
Code:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var opportunity = sforce.connection.query("Select Opportunityid From Quote where id = '{!Quote.Id}'");
var myJob1 = new sforce.SObject("Opportunity");
myJob1.Id = opportunity;
myJob1.Precisa_Cota_o_Frete__c = "true";
var result = sforce.connection.update([myJob1]);
window.location.reload();
Error Message: A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:'Unexpected element {urn:partner.soap.sforce.com}done during simple type deserialization', line:'1015', column:'29', sourceURL:'https://na23.salesforce.com/soap/ajax/20.0/connection.js', }
It already does work without the var opportunity part on the opportunity page, there just defining the Id by putting myJob1.Id = "{!Opportunity.Id }";
Any ideas? Is that cross-referencing at all possible?