I created a custom button that marks a check box from false to true. I get an error saying when I click on it and it doesn't update the check box:

Invalid left-hand side in assignment

I copied and pasted this code from another button that we use that, as far as I know, works and just changed the fields. Can someone help me figure out what is wrong with this code? I would've preferred to have used an action, but the standard object "Product2" doesn't support them apparently.

    var newRecords = []; 
    var c = new sforce.SObject("Product2"); 
    c.id = "{!Product2.Id}"; 
    {!Product2.Service_Part__c} = true; 
    result = sforce.connection.update(newRecords); 

1 Answer 1

{!Product2.Service_Part__c} = true; 

Should be:

c.Service_Part__c = true;
  • 1
    @ad_rey you're just inexperienced. You'll get it sooner or later. I can promise you that everyone everywhere that's written code has made silly mistakes when starting out.
    – sfdcfox
    Commented Oct 4, 2017 at 15:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .