Flow visibility condition - Variables have null values

03 Jun '18, 04:30 PM
1,096 Views
No Forum Badges

 

Hello,

I have a list of elements and want to add a visibility condition to the flow "Edit" of each of the rows. The condition would be to hide the flow if the date of the element is older/before than the now date. 

In the page context, I have created two variables connected to the "ListElements", which is in itself a select query, and the Date and Time properties of the element respectively. 

I also added an Activation Expression with this script:

 

#input date

#input hour

 

import java.text.SimpleDateFormat

 

def dateeee = new Date()

def dateFormat = new SimpleDateFormat("MM/dd/yyyy")

def hourFormat = new SimpleDateFormat("HH:mm:ss")

 

def nowData = dateFormat.format(dateeee)

def nowHour = hourFormat.format(dateeee)

 

Date thisDate = dateFormat.parse(nowData);

Date thisTime = hourFormat.parse(nowHour); 

 

Date myDate = (Date) date

Date myTime = (Date) hour

 

 

if (thisDate.compareTo(myDate) > 0 || (thisDate.compareTo(myDate) == 0 && (thisTime.compareTo(myTime) > 0))) {

return true

} else {

return false

} 

In the end, added to the "Edit" flow that visibility condition in the Properties. 

The problem is that from my script Im getting a NullException, and have verified that null are the variable values not the 'now date' values. 

What am I doing wrong?

 

 
x 0
Follow
Answer Answer at this question and get points!
No answers yet
Answer at this question and get points!