Here is a useful little code example that can help create complex workflows triggered by buttons.
The scenario
I wanted to perform a many activities for an advisor when they are starting to work on a client inquiry. Once an inquiry is has been picked up, the advisor needs to set up a time for a call with our client to discuss, which means sending an email meeting invite (with a link to Zoho Booking) setting up dates, making notes on work activities and creating a follow-up task should the client not respond in time.
All of the above actions can easily be orchestrated in Flow - which is far more visual than trying to code everything by hand in a Deluge function.
However, all of this activity should NOT happen automatically... the advisor has the action of following a different procedure, depending upon the client, the inquiry and background context. Instead, we want the advisor to press a button and have all of the above happen.
I am sure you could think of other scenarios where activating a ZohoFlow from a CRM button would be helpful.
How to do it
The way to do this is listed (with explanatory comments) below
// Step 1 - create a Zoho Flow workflow based on an Webhook and copy the URL provided - you will use this URL in the code that follows.
// Step 2 - create a map that holds the values you wish to pass to ZohoFlow
// These values need to be passed to the function via the button. You can do this
// by clicking the 'Edit Arguments' link at the very top of the CRM function editing window
// when you are creating this function.
// Because I am sending data related to an inquiry, I decided to call the map InquiryMap
// for clarity, but any other name works fine.
// start by defining a map variable for the information you will be passing
InquiryMap = Map();
// then add the key pairs for each field you wish to pass to Zoho Flow. You use the .put method to this.
// note than the key (the text in the quotes) will be the key name passed to Zoho Flow,
// and the second field is the data to send - in this case, the values passed via the button using the
// 'Edit Arguments' button.
InquiryMap.put("InquiryID",InquiryID);
InquiryMap.put("InquirySubject",InquirySubject);
InquiryMap.put("InquiryNumber",InquiryNumber);
InquiryMap.put("ContactFirstName",ContactFirstName);
InquiryMap.put("ContactLastName",ContactLastName);
InquiryMap.put("ContactEmail",ContactEmail);
InquiryMap.put("OwnerFirstName",OwnerFirstName);
InquiryMap.put("OwnerLastName",OwnerLastName);
InquiryMap.put("OwnerBookingLink",OwnerBookingLink);
InquiryMap.put("OwnerEmail",OwnerEmail);
// Step 3. Now you send the data to the Zoho Flow URL
// supplyURL and parameters to invoke the Flow URL
// note, the URL below comes from the Webhook setup in Zoho Flow
respondAPI = invokeurl
[
type :POST
parameters:InquiryMap
];
return "";
I hope this helps other newbies (like me) get some extra automation our of Zoho CRM and Zoho Flow. The two are made for each other!