I've seen a few topics on this but none explained it well enough for me. I want to filter Contacts by the Account Type. To do this you will need to create a
function and then associate the function with a
workflow.
I found this
post with a function that works great.
Create the Function
1. Go to Setup > Developer Space > Functions
2. Select + New Function
2. Enter Function Name, Display Name and set the Category as "Automation"
3. Copy and paste the code below into the function.
4. Click Edit Arguments and add accountId. Set type as int.
5. Save Function. (If you want to test the function you'll need to grab a Account Id that has a Account Type set.)
Create Workflow
1. Go to Setup > Automation > Workflow Rules
2. Select + Create Rule
3. Select Accounts Module, enter name, and description
4. When > On a record action > Field Update > Select Account Type
5. Click Next
6. Select All Accounts
7. Click on instant Actions, Select Function, Select the function you created
8. Save Workflow
- Acc = zoho.crm.getRecordById("Accounts", accountId.toLong()); //What does toLong() do?
- contacts = zoho.crm.getRelatedRecords("Contacts", ("Accounts"), accountId.toLong());
- for each cont in contacts
- {
- mp = map();
- mp.put("Account_Type", ifnull(Acc.get("Account_Type"),"")); //Should the underscore be removed?
- upd = zoho.crm.updateRecord("Contacts", cont.get("id"), mp);
- info mp;
- info upd;
- }
I hope you find this helpful