Fetching values of related records in parent record

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:

  1. 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"

    Fetch realted list data image1

  2. Create a new Field of text type named as "Potential Type" and save.

    Fetch realted list data image2

  3. 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.

Fetch realted list data image3

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.

Fetch realted list data image4

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.

Fetch realted list data image5

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.

Fetch realted list data image6

A default syntax of Custom function appears

Fetch realted list data image7

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.

Fetch realted list data image8

We can make use of the following function body to accomplish our task.

Fetch realted list data image9

In the above function, we have taken Potential Id(potid)of the Potential record being created/updated, as the input argument.

  1. From input argument, we may get the potential record.
  2. In the variable accountId, Potential's parent Account Id is fetched.
  3. contactRelatedrecordsholds all the related contact records of the account record found in step 2.
  4. Iterating over the records fetched in Step 3, contactId holds the contact Id of contact records in list contactRelatedrecords.
  5. 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".

Fetch realted list data image10

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