preconfigured Date to be validated

  • 23 October 2019
  • 2 replies
  • 1 view

Badge +1

Hi all,

 

First time poster :)

Project

Capture new users, changes to existing users and termination of users.

I have a ValidFrom (set as today by default) date field and ValidTo date field that has 12/31/2099 as the default date entered. 

I also have a choice(called Statusofrecord) dropdown with 3 options (Starter/Changer/Leaver).

I'm trying to create a rule that throws an error message with the following conditions

IF Statusofrecord = 'Leaver' & Validto = 12/31/2099 Then Error message.

 

I select the Statusofrecord dropdown, create a rule and tried entering this Statusofrecord=='Leaver' && ValidTogreaterThanOrEqual(formatDate('12/31/2099'))

No matter what I try (without formatting date etc) the rule doesn't apply.

If I remove the Validto part (keeping only  Statusofrecord=='Leaver') then the error message appears.

 

Could someone kindly point me in the right direction, I've been trawling through the forums, youtube and a Lynda.com course to try and find an answer.

 

thank you to anyone who can help.

 

Sharepoint is on-premise 2013


2 replies

Userlevel 6
Badge +22

Hi,

 

Add this as a validation rule to your ValidTo Date control.

Dont just cut and paste this rule, make sure you replace StatusOfRecord etc with your named controls so they turn red.

With the dates I decided to say "if the year is 2100 onwards" its invalid.

 

and(equals(StatusOfRecord,"Leaver"),greaterThan(formatDate(ValidTo,"yyyy"),formatDate("12/31/2099","yyyy")))

 

Badge +1
Thank you SimonMuntz.
I tweaked the solution with the logic you applied

and(equals(Statusofrecord,"Leaver"),greaterThanOrEqual(formatDate(ValidTo,"yyyy"),"2098"))

I appreciate the help and quick answer

Reply