Constrain a data grid to show records with 7 days before a deadline date

0
Hi, I have a data grid with source xpath.  I have an attribute called 'DeadlineResponseDate'  with format date and time I want to constrain the data grid to only show records that have 7 days until the 'DeadLineResponeDate' For example today's date is 30/11/2018 so the data grid would only show records with a 'DeadLineResponeDate' between 30/11/2018 and 6/12/2018 Is it possible to do this with an xpath constraint or will i have to use another method.   Thanks.    
asked
6 answers
7

You can easily write this in XPath constraints:

[DeadlineResponseDate >= '[%BeginOfCurrentDayUTC%]']
[DeadlineResponseDate <= '[%BeginOfCurrentDayUTC%] + 7 * [%DayLength%]']

For reference, see the documentation.

answered
1

Addition to Micha Friede's answer and the solution using the microflow:

I hope I understood what you wanted to achieve ;)

answered
1

The calculated field is useful depending on how many records you want to display that meet this criteria. If it is more than a couple dozen, I would steer away from Calculated attributes and have a Scheduled Event that sets the boolean in the background once a day. You'll gain a huge performance increase as well as only calculated once a day instead of every time the list is shown.

Source Microflow works as well (same as setting the boolean...use the addDays() function and set -7 or whatever you need), but again, that will return all records and evaluate at run time each time the list is shown whereas the Schedule Event will be a once and done set. 

I recommend the SE approach

answered
0

As always there are several options:

1) Create a boolean calulated field where you calculate the daysBetween the current date and the DeadlineResponseDate < 7 and use the boolean to filter your grid.

2) Create a source microflow that returns the records that meet the requirements.

Make sure to include notempty validation (deadline not filled in), otherwise you might get errors.

answered
0

As Micha says you'd need either a field that saves a value you can use to compare to in your xpath (like saving a date that's 7 days before your deadline and comparing the currentdate to that, or a boolean to filter on)

If you'd like to see what's possible in xpath constraints there's a neat of list of options in the documentation: 
https://docs.mendix.com/refguide/xpath-constraint-functions
https://docs.mendix.com/refguide/xpath-keywords-and-system-variables
https://docs.mendix.com/refguide/xpath-operators
 

good luck :)

 

answered
0

Yes you can use an XPath:

[ DeadLineResponeDate  < '[%BeginOfCurrentDayUTC%] + 7 * [%DayLength%]']

Regards,

Ronald

 

answered