With the recent update in Zoho Creator, we have enriched the deluge language with ‘Functions’ support.
Let’s see, ‘What is Function’ in scripting terminology. In simple terms, ‘A function is a set of statements grouped together under a name and can be invoked/reused from elsewhere in the scripting‘.
Usage of functions can be broadly classified under the following.
1).Write once and reuse utilities
2).Serves as bridge between applications (created by the same user)
3).Custom action integration in views
Write once and reuse utilities :
‘Functions’ promotes code re-usability of deluge script within an application and even across applications (same user’s applications). It makes the code modular and easy to understand.
When you feel like repeating certain scripting functionality across different parts of application, you can define them as separate function and reuse it. With the help of built-in functions provided in deluge, you can create numerous util functions on your own, using the ‘Functions’ support.
bool isLeapYear(int year)
leapyear = false;
if ((input.year % 4) == 0)
leapyear = true;
if(((input.year % 100) == 0) && ((input.year % 100) != 0))
leapyear = false;
Serves as bridge between applications (created by the same user) :
Not only can you define generic utilities as functions, you can even manipulate the application data from within the functions. Till now, it was not possible to manipulate the data in one application from the script in another application, which is now made possible with the help of functions. In this respect we can consider application as an object with its data and we can define functions to operate on this data which compares to member functions in an ‘object oriented’ world. The applications can communicate with each other using functions.
Custom action integration in views :
‘Functions’ has the potential to be integrated into various GUI actions, taking the scripting integration in Zoho Creator to next level. It makes the applications created, much more powerful and alive.
As a first step, it is integrated into views under the terminology ‘Custom Actions’. It enables the user to invoke specific function on a selected record in a view.
Custom actions in a view in live mode