AnsweredAssumed Answered

Business Rule with Map Function set output value to null while is should be true

Question asked by dprevost672266 on Mar 9, 2017
Latest reply on Mar 10, 2017 by dprevost672266

I'm using a Business Rule to validate if a Json Profile contain at least one element in an array of newHires with a date older than 6 months. To do so, I used a Map Functions that in input received the date and in output the result on if the input date is greater than the current date + 6 months. I then used this Map Function in the BR to provide the newHire startDate as input and do a conditions on the output which should be a string "true" or "false".

 

Down below there is the BR and the script.

 

My problem is that using a logger in my script and checking the Process logs, the code is doing exactly was I expect and the output should contain "true", however, in the document output the map function result seems to be null and neither "true" or "false". I do not understand why 

 

Process logs with log output of the script in the BR. From this log output the BR conditional result shoudl be result = true

 

Document logs of the BR that show that the conditional result is null ???? Why??? The output above said the variable is true

Here the BR:

 

Here the script:

IsDateGreaterOrEqualThanCurrentPlusXMonths Scripting:

import com.boomi.execution.ExecutionUtil
import org.codehaus.groovy.runtime.TimeCategory

logger = ExecutionUtil.getBaseLogger();
//logger = LoggerFactory.getLogger("Logger");


//date = new Date();

date1 = date;
date2 = new Date();

//Add X Months to date2
propName = "nbOfMonths";

// Retrieve current Process Property value
propValue = ExecutionUtil.getDynamicProcessProperty(propName);
//propValue = "6";

nbOfMonths = propValue;

logger.warning("nbOfMonths = " + nbOfMonths);
logger.warning("currentDate = " + date2);

datePlusXMonths = date2;
if (datePlusXMonths != null && datePlusXMonths != "") {
def nbOfMonthsInt = Integer.parseInt(nbOfMonths);
use(TimeCategory) {
datePlusXMonths = datePlusXMonths + nbOfMonthsInt.months;
}
}
logger.warning("datePlusXMonths = " + datePlusXMonths);

date2 = datePlusXMonths;

logger.warning("date1 = " + date1);
logger.warning("date2 = " + date2);

def result = 'false' ;
if (date1 != null && date1 >= date2) {
result = 'true';
}

logger.warning("result = " + result);

Outcomes