How to set up a workflow to retain the association between a lead and a Zoho Sign Document?

How to set up a workflow to retain the association between a lead and a Zoho Sign Document?

Scenario: Can I set up a workflow to retain the association between a lead and a Zoho Sign Document after the lead is converted to a Contact or Account?

If you are using the Zoho Sign extension in CRM, when a lead is converted to a Contact/Account, the Contact in 'Zoho Sign Documents' module will not be updated. This is a workaround step to update the details in the Zoho Sign Documents module each time a lead is converted.
  1. Navigate to Setup -> Customization -> Modules and Fields -> Leads -> Edit Layout.
  2. Add a new field of type 'Single Line' with the name 'Lead Conversion ID'.
  3. Edit the properties of this field, then select the checkbox for Also create for Account.
  4. Navigate to Setup -> Automation -> workflow rules. 
  5. Create a new rule: module = Leads.
  6. On record action -> Create -> All Leads -> create new function. 
  7. Edit arguments of the function -> set name of argument as 'leadId' and select value from 'Leads' module and 'Lead Id' field.
  8. Copy and paste the below code and save the function and workflow. 
    zoho.crm.updateRecord("Leads", leadId, {"Lead_Conversion_ID":leadId+""});
  9. Navigate to Setup-> Automation -> workflow rules. 
  10. Create a new rule: module = Contact.
  11. On record action -> Create.
  12. Set condition as 'Lead Conversion Id' is not empty-> create new function.
  13. Edit arguments of the function  and create 2 new arguments.
  14. Set name of argument as 'contactid' and select value from 'Contact' module and 'Contact Id' field.
  15. Set name of argument as 'leadConversionId' and select value from 'Contact' module and 'Lead Conversion Id' field.

    Copy and paste the below code, save function, and workflow.
  1. resp = zoho.crm.searchRecords("Zoho Sign__Zoho Sign_Documents","(Zoho Sign__Lead:equals:" + leadConversionId + ")");
  2.  if(resp.size() > 0)
  3.  {
  4.   zsID = resp.get(0).get("id");
  5.   zscontact = Map();
  6.   zscontact.put("Zoho Sign__Contact",contactId);
  7.  //Lead that is converted to Contact is updated in the Zoho Sign Documents module
  8.   info zoho.crm.updateRecord("Zoho Sign__Zoho Sign_Documents",zsID,zscontact);
  9. }