Need help with Function

Need help with Function

Hi - I am having a difficult time getting a function to work. This is a copy of a function that is already working well in our CRM, but with variable names different. So no idea why the original works and this variation won't. 

This function executes on a button click. Its intention is to change a field value. That is all. There is then a workflow and action that is triggered by the field change, that will send a specific email/email template.

Side note/rant: the fact that we have to jump through this many hoops, and "trick" the system, to simply have a button that sends an email/email template is absurd. There should be the ability to add a button that sends an email. Seems ridiculously simple and basic. Or at the VERY least, add a button that can trigger a workflow (that sends an email). But having to add a button, which triggers a function, which changes a field, which triggers a workflow, which runs an action, to send an email template, is completely ridiculous. 

"Send Email Template" and "Trigger Workflow" should be options under Custom Actions when creating a Button. I've seen these two capabilities requested for more than 6+ years on these forums and they still aren't available.


So here is the function:
  1. if(ignoreThis == "1")
  2. {
  3. mp = Map();
  4. mp.put("ignore","2");
  5. updateRec = zoho.crm.updateRecord("Deals",jobID,mp,{"trigger":{"workflow"}});
  6. info updateRec;
  7. }
  8. else if(ignoreThis == "2")
  9. {
  10. mp = Map();
  11. mp.put("ignore","1");
  12. updateRec = zoho.crm.updateRecord("Deals",jobID,mp,{"trigger":{"workflow"}});
  13. info updateRec;
  14. }
  15. return "A notification has been sent to the Job Owner that a new quote has been uploaded. Thank you.";
This saves and executes correctly, and the return works. There are no errors. The Arguments are set correctly, the variable names are correct, the field names are correct, the field values are correct. I've checked them all multiple times. When the button is clicked on the CRM side, it appears to execute and the return message is shown. But the field value is never changed - therefore the workflow is never triggered and email never sent.

If I go into the record and manually change the field to the other value, the workflow is triggered and email sent, so it is not the workflow or the action. The function is the problem, it is not changing the field value.

Any help would be super-appreciated. Thank you!

P.S. Macros also don't work for this task, and are very limited in capability. You cannot have a macro send an email template to the record owner, it will only send it to the record contact. Why the option to send to record owner is not there is perplexing.