Interstage BPM Studio Version: All versions of Interstage BPM Studio that supports Java Action Sets
The following sample script retrieves the current date and a date stored from a user defined attribute (UDA). Then an evaluation is done to see if the difference between those dates is equal to or greater than 45 days. Based on the outcome from the evaluation, a UDA of type Boolean is set to true or false.
********************************************************************
// Get current date
var date = new Date();
// Convert current date into milliseconds
var curDateToMilli = Date.parse(date);
// Get date value from a UDA of type Date
var endDate = uda.get("DateStored_UDA");
// Convert UDA date value into milliseconds
var endDateToMilli = Date.parse(endDate);
// Find the difference between the UDA date and current date in milliseconds
var dateDiff = endDateToMilli - curDateToMilli;
// Now a comparison can be made to a predefined date (in milliseconds) to see if it meets a certain criteria.
// In this case, this comparison is to see if the difference is less than or equal to 45 days. If yes, set the Boolean // type UDA, “conditionCheck” to “true”. If no, then it is set to “false”.
Author: Marc Bui
Attachment: Evaluating_Dates_Using_JavaScript_in_Interstage_BPM_Studio_Example.zip