JavaScript functions
The option to create a pflow_user.js file is not applicable in a multi-tenant environment.
This table lists the available functions that you can use for evaluating a JavaScript expression:
Data type | Function name | Parameters | Description |
---|---|---|---|
Date | today | Return the current date and time in JavaScript format | |
String | todayAGS | Return the current date and time in AGS yyyymmdd format | |
String | todayDME | Return the current date and time in DME mm/dd/yyyy format | |
Date | pfDate | var1, 'yyyymmdd' | Return a JavaScript date, given an AGS formatted date (yyyymmdd) |
Date | pfDate | var1, 'mm/dd/yyyy' | Return a JavaScript date, given a DME formatted date (mm/dd/yyyy) |
String | getDateDME | var1 | Return a date in DME mm/dd/yyyy format, given a JavaScript date |
String | getDateAGS | var1 | Return a date in AGS yyyymmdd format, given a JavaScript date |
Date | AddDay | var1, NbrDays | Add a number of days to a JavaScript date and return the new JavaScript date |
Date | AddMonth | var1, NbrMonths | Add a number of months to a JavaScript date and return the new JavaScript date |
Date | AddYear | var1, NbrYears | Add a number of years to a JavaScript date and return the new JavaScript date |
Integer | DateDiff | var1, var2 | Calculates the difference in days between two JavaScript dates (absolute value) |
Integer | getDate | jsDate | Returns the date |
Integer | getMonth | jsDate | Returns the month |
Integer | getYear | jsDate | Returns the year |
String | todayLMRK() | Returns the current date and time in the UTC
timezone and in the Landmark Timestamp format:
|
|
String | getDateLMRK() | jsDate | Given a JavaScript date, return the date and time
in the UTC timezone and in the Landmark Timestamp format:
|
String | addLeadingSpaces | varString, finalLenthOfVarString, isSpaceEscaped | Returns the String with leading space escape chars to be used while attaching a variable in form URL. Can also be used to add actual space characters instead of the escaped space char by passing false for the argument isSpaceEscaped. If the 3rd argument is not passed at all, space will be escaped and then added. |
String | addLeadingZeros | varString, finalLenthOfVarString | Returns the String with leading zero chars to be used while attaching a variable in form URL |
String | addTrailingSpaces | varString, finalLenthOfVarString, isSpaceEscaped | Returns the String with trailing space escape chars to be used while attaching a variable in form URL. Can also be used to add actual space characters instead of the escaped space char by passing false for the argument isSpaceEscaped. If the 3rd argument is not passed at all, space will be escaped and then added. |
String | addTrailingZeros | varString, finalLenthOfVarString | Returns the String with trailing zero chars to be used while attaching a variable in form URL |
String | URLEncoder | urlString | Use escape function to return URL-ready string |
String | DateString | jsDate, 'yyyymmdd' | Return a date String from js date |
String | DateString | jsDate, 'yyyymmdd hhmmss' | Return a date String from js date |
String | trim | varString | Trim leading and trailing spaces and control characters from string |
String | trimLeading | varString | Trim leading spaces and control characters from string |
String | trimLeadingSpaces | varString | Return string removing spaces at start |
String | trimLeadingZeros | varString | Return string removing zeros at start |
String | trimTrailing | varString | Trim trailing spaces and control characters from string |
String | trimTrailingCRLF | varString | Return string without CR/LF characters at end |
String | trimTrailingSpaces | varString | Return string removing spaces at end |
String | trimTrailingZeros | varString | Return string removing zeros at end |
String | substring | varString, startIndex, endIndex | Get part of a string starting from a given index to an end index |
String | substring | varString, startIndex | Get part of a string starting from a given index and the rest of the characters |
Double | round | num, decimalPlaces | Rounds off number to the number of decimal places specified by decimalPlaces |
String | base64encode | data | Encodes a given string to its base 64 format |
String | base64decode | data | Given a base 64 encoded string, converts that into readable character format |
The JavaScript functions that can be used by IPA are defined in a JavaScript file called pflow.js. In the designer, these functions are made available from the Function drop-down list in the Variable Expression Builder.
The pflow.js file is found in these two locations:
-
From the server: %LASYSDIR%\LPS
-
From the designer: base install directory
You cannot modify the pflow.js. If you need to add functions, you must create a new file called pflow_user.js and place this file in the two directories that contain the pflow.js. The pflow_user.js file must maintain the same format as pflow.js for it to work. The format should begin with a section where your functions are defined:
//*****Function Definition -->Date=today() //
//*****Function Definition -->String=todayAGS() //
//*****Function Definition -->String=todayDME() //
//*****Function Definition -->Date=pfDate(var1,'yyyymmdd') //
Any new functions must be defined for them to appear in the designer. This example shows how you can define a function in a pflow_user.js file:
/************************************************************
Function: today
Purpose: Return the current date and time in JavaScript format
*************************************************************/
function today()
{
return new Date();
}