Zoho CRM Custom Function has problem in Email

Zoho CRM Custom Function has problem in Email

Recently zoho CRM added feature to write your own custom functions, it gives the developer more flexibility in customization. However I found that when I drag the Email function to the script area, it pops up Javascript alert saying undefined twice. Not just that, If am going to insert a variable from the deluge script inside the content area and click on the done button, it pops up the same alert again and nothing happens (the Email box remains open). Due to this I can't use the Email function at all with my script. I contacted Zoho Support team and they suggested me not to use TABLE structure in the Email Content's Variable. After removing it I tried again but no success. Then decided to write a new function that only has the code to send static text email without any dynamic variable. The problem still persist like I mentioned above. I think Zoho has some issue with their Javascript and they must have to fix it. My client is being disappointed because of the delay, the error has caused. Please fix this error or let me know if I am doing something wrong. For your references following is the deluge code I am writing the Custom Function for-

  1. void workflowspace.sendEmail (string cageCode ) Edit Arguments
  2. recAccount = zoho.crm.searchRecords(("accounts") ,"(CAGE Code|=|" + input.cageCode + ")" ,1 ,1 ) ;
  3. header = "<table width='700'><tr style='border:1px solid black;text-align:center'><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>Quantity</th><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>UOM</th><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>Part Number/NSN</th><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>Stock Number</th><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>Manufacturer</th><th style='border:1px solid black;text-align:center;color:white;background-color:#1c4587'>Description</th></tr>" ;
  4. row = "<div>Department of Defense Foreign Military Sales Contract<br><br>Please advise of price and availability for resale to the US Government:<br><br></div>" + header ;
  5. for each account in recAccount
  6. {
  7.     accountId = (account).get("ACCOUNTID") ;
  8. }
  9. contactEmails = "" ;
  10. resContacts = zoho.crm.getRelatedRecords("contacts" ,("accounts") ,accountId ,1 ,200 ) ;
  11. for each contact in resContacts
  12. {
  13.     contactEmails = ((contact.get("Email")) + ",") + contactEmails ;
  14. }
  15. contactEmails = contactEmails.removeLastOccurence(",") ;
  16. res = zoho.crm.searchRecords("CustomModule1" ,"(CAGE Code|=|" + input.cageCode + ")" ,1 ,200 ) ;
  17. for each rec in res
  18. {
  19.     row = (((((((((((row + "<tr style='border:1px solid black'><td style='border:1px solid black;text-align:center'>" + rec.get("Quantity")) + "</td><td style='border:1px solid black;text-align:center'>") + rec.get("UOM")) + "</td><td style='border:1px solid black;text-align:center'>") + rec.get("Part Number/NSN")) + "</td><td style='border:1px solid black;text-align:center'>") + rec.get("Stock Number")) + "</td><td style='border:1px solid black;text-align:center'>") + rec.get("Manufacturer Name")) + "</td><td style='border:1px solid black;text-align:center'>") + rec.get("Description")) + "</td></tr>" ;
  20. }
  21. body = row + "</table><div><br><br>Best Regards,<br><br>--<br><br></div><div dir='ltr'><div><div><b style=''><font color='#0000ff'>Purchasing team</font></b></div><div><font color='#000000'>Vice President</font></div></div><div dir='ltr'><br></div></div>" ;