cancel
Showing results for 
Search instead for 
Did you mean: 

compare date in MDK with rule

0 Kudos

I have a entity set property with type as date, I want to compare it to todays date, to check if the date has passed or not.

Accepted Solutions (1)

Accepted Solutions (1)

fjcarrasco
Active Participant

kohlisamvaran76 you need to use a rule in Subhead property in Object table.

In the rule:

let today = new Date();
today.setHours(0,0,0,0);

let plndDelivDate = new Date(clientAPI.binding.PlndDelivDate);
plndDelivDate.setHours(0,0,0,0);

if(plndDelivDate < today)
  return 'Date has passed';

Answers (1)

Answers (1)

fjcarrasco
Active Participant
0 Kudos

Hi kohlisamvaran76 I had to do a date validation in order to not allow past dates in a date field. I did this in onChangeValue event of this field. Maybe it helps you:

let error = false;

let today = new Date();
today.setHours(0, 0, 0, 0);

let plannedDate = new Date(context.getValue());
plannedDate.setHours(0, 0, 0, 0);

if (plannedDate < today)
  error = true;

0 Kudos

Hi Francisco,

I am using an Object table in my list page. The OData service that I am using has a property called 'Delivery date'. I want to check if the delivery date has passed or not. If the delivery date has passed I want to return a message to the user.

Below is the Entity property.

I want to display a message like this, for every object table in the list page.

Thank you