IpeScriptUtil (and ScriptUtil) Conversion Date and Time and String Functions
The following functions are supported both in the ScriptUtil factory and, for compatibility with the TIBCO iProcess Suite, in an IpeScriptUtil factory designed for assistance in migrating iProcess scripts to BPM.
iProcess expressions support the addition and subtraction of dates and times, expressed in arithmetic form "date + num", "time - time", and so on. Operations of this kind in BPM should be performed by the supported add() or subtract() methods on the date and time objects. Functions relating to the internal operations of iProcess or its environment are not supported.
You can access these functions using either of the following:
- ScriptUtil.<FunctionName>
- IpeScriptUtil.<FunctionName>.
Return Type Syntax and Example Comments Conversion Functions Text DATESTR(Date) Field = ScriptUtil.DATESTR(DateTimeUtil.createDate());
Converts a date field into a locale-specific string, for example, 20/08/2009. Decimal NUM(Text) Field = ScriptUtil.NUM("123");
Converts String to Decimal. Text STR(Decimal DECIMAL, Integer DECIMALS) ScriptUtil.STR(2.3,2); // Generate "2.30"
Converts from Decimal to a string with a specified number of decimal places. Text STRCONVERT(Text TEXT, Integer OPCODE) ScriptUtil.STRCONVERT("test",32);
Depending on which bits are set in the opcode parameter, the following conversions are applied to the text parameter - the result is returned: 1 Delete all spaces.
2 Delete all leading spaces.
4 Delete all trailing spaces.
8 Reduce sequences of multiple spaces to single spaces.
16 Convert to lowercase.
32 Convert to uppercase.
Text STRTOLOWER(TEXT) ScriptUtil.STRTOLOWER("TEST");
Returns a lowercase copy of the string passed in. Text STRTOUPPER(TEXT) ScriptUtil.STRTOUPPER("test");
Returns an uppercase copy of the string passed in. Text TIMESTR(TIME) Converts a time field into a locale-specific string, for example, 21:23. Date and Time Functions Date CALCDATE(Date date, Integer dDy, Integer dWk, Integer dMo, Integer dYr) ScriptUtil.CALCDATE(DateTimeUtil.createDate(), 0, 0, 1, 0);
Adds an offset to a date. Note that the offset is not restricted by the units used, for example, an offset expressed as a number of days is not restricted to the number of days in a week or a month. Time Time CALCTIME(Time time, Integer dHr, Integer dMi) newTime = ScriptUtil.CALCTIME(DateTimeUtil.createTime("12:00:00"),2,40);
Adds an offset to a time. The time plus offset is returned by the function. Integer CALCTIMECARRYOVER(Time time, Integer dHr, Integer dMi) carryDays = ScriptUtil.CALCTIMECARRYOVER(DateTimeUtil.createTime("12:00:00"),2,40);
Adds an offset to a time. The function returns an integer whose value is the number of days apart. The new time is from the original time, so for a 48 hour offset, the function would return 2 (or -2 for -48hours). Date DATE(Integer day, Integer mon, Integer year) ScriptUtil.DATE(31,12,2009)
Constructs a Date. Integer DAYNUM (Date date) ScriptUtil.DAYNUM(DateTimeUtil.createDate("2001-10-08"));
Returns the day of the month of the specified date. Text DAYSTR (Date date) ScriptUtil.DAYSTR(DateTimeUtil.createDate("2001-10-08"));
Returns the day of the week as a string, for example, Monday, for the specified date. Integer HOURNUM (Time time) ScriptUtil.HOURNUM(DateTimeUtil.createTime("06:24:00"));
Returns the hour of the specified time. Integer MINSNUM (Time time) DateTimeUtil.MINSNUM(DateTimeUtil.createTime("06:24:00"));
Returns the minutes from the specified time. Integer MONTHNUM (Date date) ScriptUtil.MONTHNUM(DateTimeUtil.createDate("2001-10-08"));
Returns the month number (1-12) from the specified date. Text MONTHSTR (Date date) ScriptUtil.MONTHSTR(DateTimeUtil.createDate("2001-10-08"));
Returns the month name from the specified date, for example, January. Time TIME (Integer hours, Integer minutes) ScriptUtil.TIME(6,24);
Constructs a time. Integer Integer WEEKNUM (Date date) ScriptUtil.WEEKNUM(DateTimeUtil.createDate("2001-10-08"));
Returns the week number from the specified date. Integer YEARNUM (Date date) ScriptUtil.YEARNUM(DateTimeUtil.createDate("2001-10-08"));
Returns the year from the specified date. String Functions Integer RSEARCH ScriptUtil.RSEARCH("abc", "junkabcdefs");
Reverse search for substring in string. The indices are 1-based. Returns "5". Integer SEARCH ScriptUtil.SEARCH("abc", "junkabcdefs");
Search for substring in string. The indices are 1-based. Returns "5". Integer STRLEN (Text) ScriptUtil.STRLEN("abcdef");
Count the number of characters in a string, returning the string length. Text SUBSTR ScriptUtil.SUBSTR("abcdefgh", 3, 3);
The indices are 1-based. Returns "cde". BigDecimal getFractionalSecond(Duration dur) dstField.integerSigned = ScriptUtil.getFractionalSecond(srcField.duration);
Returns the fractional part of the seconds of the duration (0 <= value < 1.0). Int getMilliseconds(Duration dur) dstField.integerSigned = ScriptUtil.getMilliseconds(srcField.duration);
Returns the duration measured in milliseconds BDSObject copy(BDSObject) Copies a BDS object as a BDS Object so it can be included in a second collection, since each BDS object can only be referenced from one collection. List<BDSObject copyAll(SrcBDSObjectList) destList.addAll(ScriptUtil.copyAll (sourceList));
Copies all the objects in the source List returning a new List that can be passed to the add All() method of another List. Note that this is for BDS objects only. It is not for use with Process Array fields.
Void setArrayElement(arrayData, Integer index, Object value)
Set an element in a JavaScript list (that represents a process data array).
It can be used to set the existing or append a new item to the end of the list if the index is passed as the zero-based index of the last item+1 (that is, the current size of list) for example, setArrayElement(array, array.size(), value).
Object getArrayElement(arrayData, Integer index) Get an element in a JavaScript list (that represents a process data array).