Copying email from account email field to custom module

Copying email from account email field to custom module

Hi,

I have a custom module called Sage Invoices that's being fed invoice information via API from a third-party application. I need to copy the email from the custom email field in the accounts module over to the email field in the Sage Invoices module whenever an invoice is created.

When my workflow triggers I get the following error: 'value is empty and 'get.json' function cannot be applied'.

  1. getinfo = zoho.crm.getRecordById("Sage_Invoices",id);
  2. accountid = getinfo.getJson("Accounts").getJson("id").tolong();
  3. accounts = zoho.crm.getRecordById("Accounts",accountid);
  4. m = Map();
  5. m.put("Email",accounts.getJson("Email"));
  6. Sage_Invoices= zoho.crm.updateRecord("Sage_Invoices",id, m);
  7. info Sage_Invoices;
Any suggestions as to what's wrong with the above code? I'm new to Deluge.