Miscellaneous topics related to Deluge Tasks

Miscellaneous topics related to Deluge Tasks

This guide will help you with the following:
1. Cancel Delete
2. App language identification
3. getFieldNames
4. getFieldValue
5. Set Variable
6. Set field value
7. Call function
8. return deluge task
9. Success message
10. Cancel submit

1. Cancel Delete

Overview

The "cancel delete" deluge task prevents data from being removed from the database when users try to delete records. An error message will be displayed to the user, which can be customized by using the alert task before "cancel delete".
This task is generally used in conditional statements, when a user must not be able to delete a record unless a specified condition is met. 
Note: When the "cancel delete" task is triggered, all other deluge tasks except "send mail" task and API calls written in that "On Validate" section will be rolled back and won't get executed.

Syntax

  1. cancel delete;
This task can be used in the following events

Example

The following script disables the record deletion if the First Name field value is not specified
  1. if ( Name.first_name != "Null" )
  2. {
  3. cancel delete;
  4. }

2. App language identification

Overview

This task returns the language in which the application is accessed. For example, if English is the language configured for an application, the returned value is "English".
Note:
  1. This task is only applicable to Zoho Creator.
  2. The same app may be used by different users in different languages. This means the return value of this task may vary in different accounts depending on the language in which the app is accessed.
  3. This task can be executed in all workflow events.

Syntax

  1. <variable> = thisapp.localization.language();

Example

Let's say we have an application with language set to "User's browser language" in language settings. The app owner's browser language is English, and the shared user's browser language is French. The following snippet assigns the value "English" to 'language' field when executed in the app owner's account. When executed in the shared user's account, it assigns the value "French".
  1. language = thisapp.localization.language();

3. getFieldNames

Overview

The getFieldNames() function returns the link names of all the fields in a form.

Return Type

LIST

Syntax

  1. <variable> = getFieldNames();
  2. // this syntax is not applicable to custom functions
(OR)
  1. <variable> = <collectionVariable>.getFieldNames();

The following snippet fetches records based on a given criteria and then extracts the field link names from a record in the collection.
  1.  collectionVar = Registrations[Email == "john@zylker.com"];
  2.  fieldNames = collectionVar.getFieldNames();

Example 2: Fetch display name of Zoho Creator fields using API

The following script fetches the display names of all the fields from the Zoho Creator form - form1 of the application - app1:
  1.  appLinkName = "app1";
  2.  formLinkName = "form1";
  3.  authtoken = "54927XXXXXXXXXXXXXXXXXXXXXX924e3";
  4.  url = "https://creator.zoho.com/api/json/" + appLinkName + "/"+ formLinkName + "/fields?authtoken=" + authtoken;
  5.  response = invokeUrl
  6.  [
  7.  url: url
  8.  type: GET
  9.  ];
where:
responseThe KEY-VALUE variable that holds the display name of all the fields of the specified form.
urlThe TEXT that represents Zoho Creator API URL that lists all field names.
appLinkNameThe TEXT variable that holds the link name of the application from which the field names need to be fetched.
formLinkNameThe TEXT variable that holds the link name of the form whose fields need to be fetched.
authtokenThe TEXT that represents the authtoken of the Zoho Creator account from which the field names need to be fetched.

4. getFieldValue

Overview

The getFieldValue() function returns the value of a specified field.

Return Type

STRING

Syntax

  1. <variable> = getFieldValue(<fieldLinkName>);
  2. // this syntax will work in workflows except custom functions
(OR)
  1. <variable> = <collectionVariable>.getFieldValue(<fieldLinkName>);

Example

1) The following snippet fetches records based on a given criteria and then extracts the field values of the specified field and adds to a list variable.
  1.  listVar=List();
  2.  collectionVar=Registrations[Email=="john@zylker.com"];
  3.  for eachrecincollectionVar
  4.  {
  5.  fieldName=rec.getFieldValue("PhoneNumber");
  6.  listVar.add(fieldName);
  7.  }

2) The following snippet iterates through all the fields fetched using getFieldNames() task, and stores the fields along with their values in the "values" variable.
  1.  values = Map();
  2.  for each field in getFieldNames()
  3.  {
  4.  values.put(field, getFieldValue(field));
  5.  }
  6.  info values;

5. Set Variable

Overview

The set variable deluge task can be used to create a local variable containing a given value.

Return

This task returns the stored value. 

Syntax

  1. <variable> = <expression>;

 Things to keep in mind

  1. Assigning a new value to a variable declared earlier will overwrite the existing value.
  2. Variables need not be declared initially before assigning values to them.
In Zoho Creator, this task can be used in the following events

Example

The following script assigns the value 0 to variable - temp:
  1. temp = 0;

6. Set field value

Overview

The set variable deluge task can be used to assign values to form fields.

Return Type

This task returns the stored value. 

Syntax

  1. input.<field_link_name> = <expression>;

Things to keep in mind

  1. If a value is initially entered for a form in the UI, and a different value has been assigned to that field using this task in the On Validate or On Success event, the value assigned in the script will overwrite the value given in the UI when the form is submitted. 
  2. If this task is used to assign a value to a field in the On Load event, the maximum characters property for that field is ignored. However, if you start editing the field, the maximum characters property will take effect.
  3. If "No Duplicate Values" is selected, and a duplicate value is specified in the "Add Record" task, the script execution will fail.
This task can be used in the following events

Example

The following script assigns the current date value to the field "Date".
  1. input.Date = zoho.currentdate;

7. Call function

Overview

The call function deluge task is used to invoke a custom function defined in any application in your account.

Return

Based on how the function is defined, it might or might not return a value.
The data-type of the returned value will be the data-type specified for the function while defining it.

Syntax

To invoke a function which returns a value, from current application
  1. <variable> = thisapp.<function_name>(<parameters>);
To invoke a function which does not return any value, from current application
  1. thisapp.<function_name>(<parameters>);
To invoke a function which returns a value, from different application in same account
  1. <variable> = <application_link_name>.<function_name>(<parameters>);
To invoke a function which does not return any value, from different application in same account
  1. <application_link_name>.<function_name>(<parameters>);

This task can be used in the following events

Example

1) Let's say we have defined a function in "Salary" application to calculate the average salary of a department:
  1. int getAvgSalary(String designation)
  2. {
  3. avgSalary=Employee[Designation = designation].avg(salary);
  4. return avgSalary
  5. }
We can invoke the defined function, for the "Sales" department, in the same app using the following snippet:
  1. Average_Sales_Salary = thisapp.getAvgSalary("Sales");
We can invoke the defined function, for the "Sales" department, in another application using the following snippet:
  1. Average_Sales_Salary = Salary.getAvgSalary("Sales");

8. Return Deluge Tasks

Overview

Functions are of two types - one which return a value, and the other which does not.
The return deluge task is used to specify the return value while using a function (which returns a value).  
Note:
The return deluge task can be used only if a return type has been specified while creating the function.

Return

When the function is invoked, the value of the expression specified in the return statement will be returned.

Syntax

  1. return <expression>;

This task can be used in the following events

Example

The following function returns the number of days between two given dates
  1. int thisapp.CalculateDays(date sdate, date edate)
  2. {
  3. days = (((edate-sdate)/86400000)).toLong();
  4. return days;
  5. }

9. Success message

Overview

The success message deluge task is used to display a specified message after a form is successfully submitted.
The message specified in this task overrules the message specified through UI in form properties.

Syntax

  1. success message <expression>;

This task can be used in the following events

Example

The following snippet when triggered displays the specified success message.
  1. success message "Thanks for your feedback";

10. Cancel submit

Overview

The "cancel submit" deluge task prevents data from getting added to the database when users submit the form. An error message "Invalid entries found" will be displayed to the user, which can be customized by using the alert task before "cancel submit".
This task is generally used in conditional statements, when a user must not be able to submit a form unless a specified condition is met. 
Note:
  1. When the "cancel submit" task is triggered, all other deluge tasks except "send mail" task and API calls written in that "On Validate" section will be rolled back and won't get executed.
  2. The "cancel submit" task also applies when data is being submitted through the Email Data feature or the Import data feature 

Syntax

  1. cancel submit;
This task can be used in the following events

Example

The following script disables the form submission if the First Name field value is not specified
  1. if ( Name.first_name == "Null" )
  2. {
  3. cancel submit;
  4. }

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION









                                    You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                        Manage your brands on social media

                                          Zoho Desk Resources

                                          • Desk Community Learning Series


                                          • Digest


                                          • Functions


                                          • Meetups


                                          • Kbase


                                          • Resources


                                          • Glossary


                                          • Desk Marketplace


                                          • MVP Corner


                                          • Word of the Day


                                            Zoho Marketing Automation

                                              Zoho Sheet Resources

                                               

                                                  Zoho Forms Resources


                                                    Secure your business
                                                    communication with Zoho Mail


                                                    Mail on the move with
                                                    Zoho Mail mobile application

                                                      Stay on top of your schedule
                                                      at all times


                                                      Carry your calendar with you
                                                      Anytime, anywhere




                                                            Zoho Sign Resources

                                                              Sign, Paperless!

                                                              Sign and send business documents on the go!

                                                              Get Started Now




                                                                      Zoho TeamInbox Resources



                                                                              Zoho DataPrep Resources



                                                                                Zoho DataPrep Demo

                                                                                Get a personalized demo or POC

                                                                                REGISTER NOW


                                                                                  Design. Discuss. Deliver.

                                                                                  Create visually engaging stories with Zoho Show.

                                                                                  Get Started Now









                                                                                                      • Related Articles

                                                                                                      • Deluge Error Messages

                                                                                                        This guide helps you with the following: Save Errors Runtime Errors Runtime Errors: Built-In Functions Save Errors Save error is a type of error that prevents the user from saving their script. This type of errors mostly occurs due to incorrect ...
                                                                                                      • Deluge Limitations

                                                                                                        This guide help you with the following: Statement Limitation Recursive Function Limitation Task Limitation Sendmail Task Limitation InvokeUrl Task Limitation Time Zone Limitation Statement Limitation The maximum number of statements that can be ...
                                                                                                      • Deluge Editor

                                                                                                        The Deluge editor offers a wide range of operations that can be performed in terms of ease of use, feature exploration and accelerate coding speed. Color schemes Deluge editor provides distinction between the various language components using a ...
                                                                                                      • Deluge Scripting - Overview

                                                                                                        Deluge (or Data Enriched Language for the Universal Grid Environment) is Zoho's scripting language for customizing Zoho CRM and other Zoho software. Zoho CRM is designed to be customized by any user, but some users have complex sales processes that ...
                                                                                                      • Getting Related Records

                                                                                                        This guide will help you with the following: Syntax Example Response Format You can fetch related information (Notes, Tasks, Contacts, etc.) about a record in an Extension or Vertical Solution using the zoho.crm.getRelatedRecords() deluge task. ...
                                                                                                        Wherever you are is as good as
                                                                                                        your workplace

                                                                                                          Resources

                                                                                                          Videos

                                                                                                          Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                          eBooks

                                                                                                          Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                          Webinars

                                                                                                          Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                          CRM Tips

                                                                                                          Make the most of Zoho CRM with these useful tips.



                                                                                                            Zoho Show Resources