📜 ⬆️ ⬇️

Acquaintance with the programming language Deluge. Creating an arbitrary function in the Zoho CRM system

In early 2015, I published an article about Zoho CRM , in which I described the functionality of this system, but did not consider the issues of its refinement. Now I decided to tell about the revisions in more detail, since in practice this turned out to be very relevant. I have been working with the system for more than a year, and it is often necessary to refine it for certain user requests.

Refinements of the Zoho CRM system are made in the Deluge language, developed by Zoho itself. Deluge is also integrated into the Zoho Creator product, but in this article we will look at using the language specifically in Zoho CRM.


What is a Deluge?


Definition from the site (translation from the site).
Deluge (Data Enriched Language for the Universal Grid Environment) is an online programming language that helps add various types of business logic to arbitrary functions and make them more powerful.

Deluge and ZOHO CRM


In Zoho CRM, the Deluge language is used when writing the so-called Custom function.
Custom function is an arbitrary function that allows you to modify the behavior of the system in accordance with the wishes of users, without being tied to any predefined settings.

Where do I propose to begin acquaintance with this language? There are many examples of its use on the Zoho website, but I decided to give a real example from my practice. A very simple and illustrative example in which the main points of working with a language and demonstration of its capabilities will be seen.

Example Description


We consider how to create a function that was implemented on one of the projects. The feature is called Contacts Phone Validate. The task of the function is to verify that the users have filled in the phone number of the contact person in Zoho CRM.
')
The function should work as follows:


The phone may be wrong for several reasons:


So, let's look at this example, how the creation of an arbitrary function in the Zoho CRM system takes place by means of the Deluge language.

The function is configured directly in the Zoho CRM user account and is available to users with rights to control the Workflow workflow.

At once I want to draw your attention to the fact that in view of the non-ideal localization of the Zoho CRM system, we will consider setting up the function in English.

Add arbitrary function


Adding an arbitrary function includes the steps:


Consider in detail each of the stages.

1. Programming function


In order to program an arbitrary function, follow these steps:

1. Go to Setup> Automation> Workflow> Custom Function
2. On the Custom Functions page, click Configure Custom Function
3. Next, click Write your own.



4. In the window that opens, do the following:





5. Write the required function in the Deluge Script Designer.

In our example, the function looked like this. We declare variables:

mapVariable=map();//    Map ( https://www.zoho.com/creator/help/script/create-map.html ) errorType=""; //      

We check the correctness of the input format and territorial affiliation:

 if(input.contactPhone.startsWith(("+7"))) //   +7,     + { errorType="     7XXXXXXXXXX!"; } else if(input.contactPhone.startsWith(("+89"))) //    +89 { errorType=(" +89   ZOHO CRM!"); } else if(input.contactPhone.startsWith(("+84"))) //    +84 { errorType=(" +84   ZOHO CRM!"); //   } else if(input.contactPhone.startsWith("7")) //    7   { if(input.contactPhone.length() != 11) //     11  { errorType=("      11 !"); } else { phoneType="RUSSIA"; //   } } else if(input.contactPhone.startsWith(("+"))) //    +,    7,    { phoneType="INTERNATIONAL"; } else { errorType="  "; } 

Check for errors:

 if(errorType != "") //     -   { mapVariable.put("Phone error","  "); mapVariable.put("Phone","-"); sendmail //      email  [ from:zoho.loginuserid to:zoho.loginuserid subject:"Phone format error |   " message:"  ! .   CRM!<br>Phone format is not correct! Look through the CRM manual!<br>Error message for phone number <b>" + input.contactPhone + "</b> is: " + errorType + "!" content type:HTML ] updateAccount = zoho.crm.updateRecord("Contacts",input.contactId.toString(),mapVariable); //      CRM } 

If the number is OK, then we check for duplicates:

 else //       { contactPhone=input.contactPhone.replaceAll("\D",""); //     if(phoneType == "INTERNATIONAL") { contactPhone="+" + input.contactPhone; } mapVariable.put("Phone",input.contactPhone); prevRecord = zoho.crm.searchRecords("Contacts","(Phone|=|" + input.contactPhone + ")",1); //        if(prevRecord.size() > 0) //    { i=0; for each account in prevRecord //       { if((((account).get("CONTACTID")).toLong() != input.contactId) && (i == 0)) //       { i=1; mapVariable.put("Phone error","   !"); mapVariable.put("Phone","-"); sendmail //           [ from:zoho.loginuserid to:zoho.loginuserid subject:"Duplicate Phone |  " message:((((((("   <br>Phone in Contact(" + (account).get("CONTACTID")) + ") is duplicated<br>Phone ") + (account).get("Phone")) + "<br>Owner: <a href='https://crm.zoho.com/crm/ShowSetup.do?tab=usersPermi&subTab=viewUser&userId=") + (account).get("SMOWNERID")) + "'>") + (account).get("Contact Owner")) + "</a><br>   " content type:HTML ] } } } else { mapVariable.put("Phone error",""); } updateAccount = zoho.crm.updateRecord("Contacts",input.contactId.toString(),mapVariable); //   . } 

6. After writing the function, you need to check the code. Click Save and Execute Script. You want to test the script by typing the values ​​of the arguments in the pop-up window. If there are no errors, your script is ready to be associated with the Workflow workflow rule.



7. Click Save to save the script.



2. Binding the function to the Workflow Rules workflow rule


To associate a custom function with a workflow rule, go to Setup> Automation> Workflow Rules, then click Create Rule.

Do the following:

1. Select the required module from the drop-down list (in our case, this is the Contacts module), set the name and description of the rule.



2. In the Rule Trigger section, select Create or Edit.



3. In the section Rule Criteria set the criteria
4. In the Actions section, select Call Custom Function.








5. Click Save.

Now our function is associated with the Workflow workflow rule, and when entering the wrong phone format, or when duplicating a number, the user receives an error message.

Conclusion


We saw how to create a function in Zoho CRM using the Deluge language and how this function works within the system. Creating a function in the Deluge language is not a complicated thing, which allows you to modify the behavior of the Zoho CRM system in accordance with your wishes and greatly expands the capabilities of the program.

I will tell you about using Deluge in another Zoho product - Zoho Creator in the next article.

Source: https://habr.com/ru/post/272421/


All Articles