2

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.

   {!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")} 
    var newRecords = []; 
    var c = new sforce.SObject("Product2"); 
    c.id = "{!Product2.Id}"; 
    {!Product2.Service_Part__c} = true; 
    newRecords.push(c); 
    result = sforce.connection.update(newRecords); 
    window.location.reload();

1 Answer 1

3
{!Product2.Service_Part__c} = true; 

Should be:

c.Service_Part__c = true;
1
  • 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 .