Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Compare Planned start date with current date time

Nithin21
Tera Expert

On Change task, I want to check if Planned start date is in future. 

If future, abort action 

if past, continue

 

I tried the below code in Client script but doesn't validate. 

 

 

find_real_file.png

var plannedStart = g_form.getValue('planned_start_date');
//get Date object using user's display format
var tzPlan = getDateFromFormat(plannedStart, g_user_date_time_format);
	
var currentDt = new Date();
if(tzPlan > currentDt)
return false;
1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi 

 

Try the below code in client script

 

 

       var start_d = getDateFromFormat(g_form.getValue('planned_start_date'), g_user_date_time_format);

 

                      var end_d =new Date();

                      if (start_d > end_d) {

              return false;

                      }   

Regards

Ravindra

 

View solution in original post

5 REPLIES 5