Skip to main content
Nintex Community Menu Bar
Question

how to validate future date( > today) in snippet

  • July 10, 2024
  • 3 replies
  • 34 views

Forum|alt.badge.img+6

in my model i have a field like expected_start_date__c. this date should be future date. how to write snippet code for this validation. Thanks in advance

3 replies

Forum|alt.badge.img+5

Hi raj

This is pretty simple. You just need to compare the two dates using common operators:

var today = new Date(), &nbsp; &nbsp; tomorrow = new Date();<br />tomorrow&#46;setDate(tomorrow&#46;getDate() + 1);<br />console&#46;log(today &gt; tomorrow); &#47;&#47;false<br />console&#46;log(today &lt; tomorrow); &#47;&#47;true<br />console&#46;log(today == tomorrow); &#47;&#47;false 

Try it out and play with it. Alter the script to fit your needs and you should be good to go.

Cheers


Forum|alt.badge.img+6
  • Author
  • July 10, 2024

my requirement for that field is , if that field is null or undefined or past date, then i want throw error message.how to add the future date in if condition


if (Startdate === ‘’ || Startdate === null || Startdate === undefined ) {


    editor.handleMessages(
       
        [{
          
            message: ‘Please Enter Expected start date and Expected date should be future date’,
            severity: ‘ERROR’
        }]
    );

    return false;
}


Forum|alt.badge.img+18

raj, you need to get your salesforce date into javascript and then compare it to a new Date().
take a look at http://help.skuidify.com/m/11720/l/129505-skuid-time