Identify and label the top accounts

Identify and mark the top accounts in your CRM by verifying if an account has associated member accounts but does not have a parent account for itself.

In an account hierarchy, the top account is the ultimate parent, and the parent account is the immediate parent to its child/member account. You can identify the top accounts as those with child accounts underneath them and without a parent account for themselves. However, filtering and organizing the top accounts in your CRM can be tedious, especially when the current filters (such as the parent account is empty) gather both parent accounts and accounts without any member accounts. This is where a custom function can come in handy.

To accomplish this task, you can utilize a low-code custom function that checks if an account has related member accounts and whether the Parent Account field is populated. If the field is empty, the function automatically marks a custom checkbox field on the account. This means you can quickly identify and label the top accounts in your CRM.

Permissions and availability

  • Users with the Modules Customization permission can add custom fields.
  • Users with the Manage Automation permission can create and update workflow rules.
  • Users with the Manage Extensibility permission can create custom functions.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Add a checkbox field in the Accounts module. This field will be checked to identify an account as a top account. Learn more
  • Create a workflow rule for the Accounts module that triggers when creating or editing an account with an empty Parent Account field. Learn more
  • Write a custom Deluge function and link it up with the workflow rule. Learn more
  • Test the workflow rule in a sandbox before deploying it to your production environment. Learn more

Add a custom field

The first step is adding the custom checkbox field to the Accounts module.

  1. Navigate to Setup > Customization > Modules and Fields.
  2. Click the Accounts module to open the layout editor.
  3. Drag and drop the Checkbox field from the New Fields tray to the desired section of the layout.
  4. Name the checkbox field (e.g. "Top Account") and define its properties as required.
  5. Once you have finished, click Save and Close.
Add Custom Field

Create a workflow rule

Follow the below steps to create a workflow rule that identifies and marks the top account.

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select Accounts from the module dropdown list.
  3. Provide a name for the rule. For example: "Identify and label the top account".
  4. Add a description (optional) and then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose Record Action, then select Create or Edit from the dropdown.
    2. Check the box for Repeat this workflow whenever a Account is edited.
    3. Click Next.
  6. In the Which accounts would you like to apply the rule to? section, specify the condition as "<Parent Account> <is empty>" and click Next.
  7. Under Instant Actions, select Function and Write your own.
  8. Provide a name and description, if necessary, for the function.
  9. On the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Edit Arguments.
    3. Choose Accounts - Account Id, name it accountId, then click Save.
    4. Click Save & Execute Script.
  10. Click Save on the workflow rule page.

The code

Code Copied
child = zoho.crm.getRelatedRecords("Child_Accounts", "Accounts", accountId.toLong());
info child.size() ;
if ( child.size() != 0 ) 
{
info zoho.crm.updateRecord("Accounts", accountId.tolong(), {"Top_Account":true}) ;
}

Note

  • Make sure to use the accurate API names for their corresponding fields (e.g., "Top Account") in the code snippet. Learn more

Tip

  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Navigate to the Accounts module.
  2. Open an account record with member account(s) underneath it and without a parent account.
  3. On the Account Details page, update any field and then click Save.
    The workflow rule will be triggered.
  4. Check whether the "Top Account" checkbox field on the account is selected to indicate it as the top account.

Ideas

  • Use the Top Account field in the list views to filter and view top accounts in your CRM.
  • To apply this workflow rule to your existing accounts, follow these instructions:
    • Apply the <Parent Account> <is Empty> filter to your list of accounts, then click Apply Filter.
    • Click the Mass Update button after selecting the filtered records on the list page.
    • Select an unused field, input its value, then click Update in the mass update window.
      You can also create a custom field for this purpose.
    • The workflow rule will trigger, identify, and mark top accounts in the selected records.

Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.

More info

  • ModuleAccounts
  • Trigger PointWorkflow Rule
  • EditionEnterprise and above
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

Custom FieldWorkflow RuleDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!