Keep track of your business details with a Company or a Contact.

Business scenario:

Keeping a check on the working capital lets you have an overview of your inventory and you can make plans to maintain your stocks. The vendor management side of CRM helps you with that. However, moving further on your business, you would have to keep regular contact with some of your patrons. Not just patrons, for each deal made with a company(Account) or a contact, there is a need to keep records of the products/services involved in the transaction. Although there is a related list that lets you do that, all of the information are Inventory-centric and not Contact or Account-centric. In other words, some additional information about the product, the exact products involved in the deal cannot be captured perfectly.

This procedure is vital in a business as it helps in gathering data for analyzing and forming better long-term business strategies. Assume there are 2 Customers, A and B, who buy 3 products each. You create an 2 Invoices, one for each. Your inventory gets updated and shows the remaining stock, but it doesn't show to whom the products were delivered. Through this function, you can use the information from the Invoice to place the product details of the transaction within the Contact or Account(Company) record to which the Invoice was sent to.

Setting this function as a button is not a practical, so we suggest placing this function in a Workflow rule to incorporate this process into your business process.

Getting started with the function:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Product details from Invoice to Contact/Account".
  3. Select the moduleto be associated as Tasks. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "invoiceId" and select the value as "Invoice Id".
  7. Enter the name as "acctId" and select the value as "Account Id".
  8. Enter the name as "contId" and select the value as "Contact Id".
  9. Click Save & Execute Script.
  10. Save the changes.

The code:

For v2 Editor - DRE:

respMap = zoho.crm.getRecordById("Invoices", input.invoiceId.toLong());
accountId = ifnull(respMap.get("Account_Name"),"").get("id");
contactId = ifnull(respMap.get("Contact_Name"),"").get("id");
productDet=ifnull(respMap.get("Product_Details"),"");
pdlist=List();
for each eachProd in productDet
{
productvalue = eachProd.get("product");
proid = productvalue.get("id");
mp=map();
mp.put("PRODUCTID",input.proid);
resp = zoho.crm.updateRelatedRecord("Products",proid,"Accounts",accountId.toLong(),mp);
info resp;
resp1 = zoho.crm.updateRelatedRecord("Products",proid,"Contacts",contactId.toLong(),mp);
info resp1;
}

Found this useful? Try it out and let us 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