Calculate Days
Function to calculate the number
of days between two given dates. The function returns an integer value.
Function Definition:
int Calculations.CalculateDays(date sdate, date edate) { days = (((input.edate - input.sdate) / 86400000)).toLong(); return days; }
|
where,
int - type of data returned by this function is of type int.
Calculations - is the namespace under which the Function is created.
CalculateDays - is the function name.
sdate - argument of type date.
edate - argument of type date.
Function Call:
The function CalculateDays is called in the on add -> on success
script, which updates a numeric form field Number_of_days with the
value returned by the function.
on add { on success { input.Number_of_days = thisapp.Calculations.CalculateDays(input.Start_Date, input.End_Date); } }
|
Date Format
Function to get the month,
year and date of a given date. The function returns the input date as a string
in the format "day/month/year", for example 12/2/2008
Function Definition
string dateformat.getAustralian(date inputdate) { month = inputdate.getMonth(); day = inputdate.getDay(); year = inputdate.getYear(); outputstr = day + "/" + month + "/" + year; return outputstr; }
|
isLeapYear()
Function to check if the
given year is a leap year. The function returns a boolean value 'true', if the
given year is a leap year.
Function Definition
bool isLeapYear(int year) { leapyear = false; if ((input.year % 400) == 0) { leapyear = true; } else if ((input.year % 100) == 0) { leapyear = false; } else if ((input.year % 4) == 0) { leapyear = true; } return leapyear; }
|
nextLeapYear()
Function to return the
next leap year based on a given year. Here, the function calls another function
isLeapYear() .
Function Definition
int nextLeapYear(int year) { input.year = (input.year + 1); if (thisapp.isLeapYear(input.year)) { return input.year; } else { return thisapp.nextLeapYear(input.year); } } |
Email Notification
Function to send
mail to selected records in a view.
Function Definition
void Email.EmailNotification(string toaddress) { sendmail ( To : input.toaddress From : zoho.adminuserid Subject : "Subject of the email" Message : "Your message" ) }
|
Custom Action
The function Email Notification is configured as Custom Action in
the View definition. The value of the EmailId field in the form is
passed as the argument value.
custom actions ( "Send Mail" : Email.EmailNotification(toaddress = EmailId) )
|
Update Field Value
Function to update
the value of Travel_Status field in the SampleForm to "Confirmed",
for selected records in the view.
Function Definition
void test.ConfirmTrip(int id) { rec = SampleForm [ID == input.id]; rec.Travel_Status = "Confirmed"; }
|
Custom Action
The function ConfirmTrip is configured as Custom Action in the View
definition. The value of the ID field of the selected records will
be passed as the argument value.
custom actions ( "Confirm" : test.ConfirmTrip(id = ID) )
|
Note: |
Change the form and field names based on your requirement. |