Turn a Contact into a Vendor.

Business Scenario

The Vendors module in Zoho CRM facilitates efficient tracking of all vendor related details. It lets you create and associate vendor records with address, contacts, products, and such. We recommend this method for creating vendor records. However, what if you have a scenario where the vendor is already a part of your Leads/Contacts module via inbound communication? It is unproductive and redundant work to update Vendors module again for the records already updated.

Functions help you overcome this hurdle. It gives you the flexibility of replicating the details from the Leads/Contacts module to the Vendors module at the click of a button.

Getting started with the function

  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "Create Quote from deal". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click "Edit arguments".
  7. Enter the name as "contactId" and select the value as "Contact Id".
  8. Click Save & Execute Script.
  9. Save the changes.
  10. Select the profiles who can view this button.
  11. Click Save.

The Code: For V1 API - Old Editor:

This example code is for creating a record in Vendors module from Contacts module.

contDetails = zoho.crm._getRecordById("Contacts",
input.contactId.toLong()); first = ifnull(contDetails.get("First Name"),"");
last = ifnull(contDetails.get("Last Name"),"");
name = "CLIENT : " + first + " " + last;
mp = map();
mp.put("Vendor Name", name);
mp.put("Phone", ifnull(contDetails.get("Mobile"),""));
mp.put("Email", ifnull(contDetails.get("Email"),""));
mp.put("Currency", ifnull(contDetails.get("Currency"),""));
mp.put("Street", ifnull(contDetails.get("Mailing Street"),""));
mp.put("State", ifnull(contDetails.get("Mailing State"),""));
mp.put("City", ifnull(contDetails.get("Mailing City"),""));
mp.put("Zip Code", ifnull(contDetails.get("Mailing Zip"),""));
mp.put("Country", ifnull(contDetails.get("Mailing Country"),""));
mp.put("SMOWNERID", "1234567890");
mp.put("Primary Contact", ifnull(contDetails.get("CONTACTID"),""));
create = zoho.crm._create("Vendors", mp);
info mp;
info create;
return "Vendor Created Successfully";

The Code: For V2 API - DRE Editor:

contDetails = zoho.crm.getRecordById("Contacts", input.contactId.toLong());
fullname = ifnull(contDetails.get("Full_Name"),"");
name = "CLIENT : " + fullname;
mp = map();
mp.put("Vendor_Name", name);
mp.put("Phone", ifnull(contDetails.get("Mobile"),""));
mp.put("Email", ifnull(contDetails.get("Email"),""));
mp.put("Currency", ifnull(contDetails.get("Currency"),""));
mp.put("Street", ifnull(contDetails.get("Mailing_Street"),""));
mp.put("State", ifnull(contDetails.get("Mailing_State"),""));
mp.put("City", ifnull(contDetails.get("Mailing_City"),""));
mp.put("Zip_Code", ifnull(contDetails.get("Mailing_Zip"),""));
mp.put("Country", ifnull(contDetails.get("Mailing_Country"),""));
mp.put("Owner", "1234567890");
mp.put("Primary_Contact", ifnull(contDetails.get("id"),""));
create = zoho.crm.create("Vendors", mp);
info mp;
info create;
return "Vendor Created Successfully";

Note:

  • The code is zoho.crm._getRecordById for Version 1.0 of.
  • This function creates a record in a module with the information from another module, reducing duplicate work and improving efficiency.
  • Change the name of the module from 'Contacts' to the intended module name and update the code accordingly.

Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips