There may be a scenario where we would want to capture certain field values of a child record to a parent record's related records in Zoho CRM. For example, there may be a scenario in which, we would like the capture the "Potential Type" of Potential record into its parent Account record's related Contact records.
To accomplish such goals, we may follow the following steps:
- Create a custom field in Contacts module where you would like to capture the Potential Type: Go to Home Page ->Setup->Customization->Fields Select Module List as "Contacts"
- Create a workflow. Go to Home Page->Setup->Automation->Workflow->Rules->Create Rule Select Module as the Child module (Potentials in this case). Give a name to the rule and some description and click Next.
Create a new Field of text type named as "Potential Type" and save.
Now select an option for "Execute On". Since we need to update the parent record everytime a new Potential record is created or edited, we choose it Create or Edit here and click Next.
While putting keys and values in this map, we make sure that the key part should have the name of the CRM field, and the value part should have the corresponding field of the stateless form, whose value is supposed to be pushed into the CRM field, used in the key.
Then we select a rule criteria, on which this rule will be triggered. Since we need to update Potential Type in parent contact record, we have taken the rule criteria that the Type in Potential record should not be null and choose that the rule should be executed whenever the specified criteria meets. Click Next.
For cross module update of fields, we need to use custom functions in Actions. Click on "+" sign next to "Call Custom Functions" and click on Write your own. You may start writing your own function here.
A default syntax of Custom function appears
Click on Edit Arguments and select the input argument as Potential ID of the record on which the rule is going to be triggered and click on Done.
We can make use of the following function body to accomplish our task.
In the above function, we have taken Potential Id(potid)of the Potential record being created/updated, as the input argument.
- From input argument, we may get the potential record.
- In the variable accountId, Potential's parent Account Id is fetched.
- contactRelatedrecordsholds all the related contact records of the account record found in step 2.
- Iterating over the records fetched in Step 3, contactId holds the contact Id of contact records in list contactRelatedrecords.
- For each record in contactRelatedrecords, the Potential Stage and Potential Name fields of contact records are updated with the values of Potential Stage and Potential Name in Potential record fetched in Step 1.
Once the deluge script is written, click "Save and Associate".
Click on Save. The workflow rule will be saved. Now, whenever a new potential record will be created or existed one would be edited, the "Type" value of the Potential record will be copied to "Potential Type" field of the parent Account record and then to related Contact records to that Account.
For any query contact support@astreait.com