Kaizen 148 - trigger in Records APIs

Kaizen 148 - trigger in Records APIs



Hello everyone!
Welcome to another week of Kaizen!
In today's post, we will discuss the "trigger" key in the Insert, Update, and Upsert records APIs.

What is "trigger"?

"trigger" is a key of the JSON type array. You can use this key in insert, update, or upsert records APIs to:
  • trigger workflows
  • make the records enter a blueprint
  • send records for approval
  • start the path finder journey of the record

JSON format

{
"data": [
],
"trigger": ["workflow", "blueprint", "approval", "pathfinder", "orchestration"]
}

Key Points

  • If you do not include the "trigger" key, all automation actions like workflow, blueprint, approval, etc, will be triggered if the conditions are met.
  • If you include the "trigger" key and specify the automation actions, the specified actions will only be triggered.
  • If you include an empty array for the "trigger" key, no automation actions will be executed.

Let us consider a sample use case where Zylker Inc. wants to close the deals when the amount is greater than $50,000, within a week after they were created or edited.
Zylker Inc has set up a workflow "Notify Record Owner". this workflow is triggered whenever the Deal Amount is greater than $50,000, and creates a ask to the record owner to close the deal within a week. The workflow also includes reminders.
Here is a glimpse of the workflow.



1. The default flow

Automation rules have a set of conditions that allow the records to fall into that process when these conditions are met.
So, when you create/update/upsert a record, and that record matches the criteria in any of the automation rules, those rules are triggered automatically. Hence, you need not specify the 'trigger' key in the input body.
In the below example, the insert records API does not have the "trigger" key, but the workflow is triggered.



2. An empty 'trigger' array

Sometimes, you do not want any of the automation actions to trigger when you create, update, or upsert a record. In that case, you can pass an empty array to the trigger key. An empty trigger array prevents the execution of automation rules.

Request URL: {{api-domain}}/crm/v6/Leads
Input:
{
"data": [
{
"Deal_Name": "Kaizen deal 1",
"Amount": 65000,
"Stage": "Negotiation/Review",
"Pipeline": "Standard (Standard)",
"layout_id": {
"id": "3652397000000091023"
},
"Lead_Source": "Employee Referral"
}
],
"trigger": []
}

In the following GIF, you can see that the workflow is not triggered.



3. Trigger specific automation action

Many times, when a record is created or edited, the criteria in more than one automation action may match. For example, a record creation can trigger both workflow and blueprint, but you want to trigger only the workflow.
In this case, you must pass only the value "workflow" to the trigger key.
Here is the input JSON.

{
"data": [
{
"Deal_Name": "Kaizen deal 2",
"Amount": 65000,
"Stage": "Negotiation/Review",
"Pipeline": "Standard (Standard)",
"layout_id": {
"id": "3652397000000091023"
},
"Lead_Source": "Employee Referral"
}
],
"trigger": ["workflow"]
}

This triggers only the workflow and prevents the execution of other automation actions such as blueprint, approvals, orchestration etc. Similarly, if you want to trigger only the blueprint, pass the value "blueprint" to the trigger array.

Equivalent Deluge Script using v2 Integration Task

mp=map();
mp.put("Deal_Name","Kaizen Deal 3");
mp.put("Amount",90000);
mp.put("Account_Name","ABC");
mp.put("Stage","Negotiation/Review");
mp.put("Pipeline","Standard (Standard)");
mp.put("Layout", "3652397000000091023");
mp.put("Lead_Source","Employee Referral");
mp.put("Closing_Date","2024-07-30");

resp= zoho.crm.createRecord("Deals",mp,{"trigger":{"workflow"}});
info resp;

Here is the task created through the workflow after executing this function.


Similarly, you can pass the required values to the trigger key to execute the required automation actions.

We hope you found this post useful. Let us know your thoughts in the comments or write to us at support@zohocrm.com.
We'll see you next week with another interesting topic.


Cheers!

      Zoho Developer Community









                                Zoho Desk Resources

                                • Desk Community Learning Series


                                • Digest


                                • Functions


                                • Meetups


                                • Kbase


                                • Resources


                                • Glossary


                                • Desk Marketplace


                                • MVP Corner


                                • Word of the Day



                                    Zoho Marketing Automation


                                            Manage your brands on social media



                                                  Zoho TeamInbox Resources

                                                    Zoho DataPrep Resources



                                                      Zoho CRM Plus Resources

                                                        Zoho Books Resources


                                                          Zoho Subscriptions Resources

                                                            Zoho Projects Resources


                                                              Zoho Sprints Resources


                                                                Qntrl Resources


                                                                  Zoho Creator Resources


                                                                    Zoho WorkDrive Resources



                                                                      Zoho Campaigns Resources


                                                                        Zoho CRM Resources

                                                                        • CRM Community Learning Series

                                                                          CRM Community Learning Series


                                                                        • Tips

                                                                          Tips

                                                                        • Functions

                                                                          Functions

                                                                        • Meetups

                                                                          Meetups

                                                                        • Kbase

                                                                          Kbase

                                                                        • Resources

                                                                          Resources

                                                                        • Digest

                                                                          Digest

                                                                        • CRM Marketplace

                                                                          CRM Marketplace

                                                                        • MVP Corner

                                                                          MVP Corner





                                                                            Design. Discuss. Deliver.

                                                                            Create visually engaging stories with Zoho Show.

                                                                            Get Started Now