Planned Start Date Validation

ktjstn
Kilo Expert

I want to make a Planned Start Date Validation wherein a pop-up message will appear if the selected Planned Start Date is more than 7 days to the current date.

 

Thanks!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kate,

So the planned start date should not be more than 7 days from now

You can use UI policy on change request table for this with condition as below:

find_real_file.png

 

find_real_file.pngscript: for execute if true

alert("Please select planned start date within 7 days from now");
g_form.clearValue('planned_start_date'); // use proper field name here

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Kate,

So the planned start date should not be more than 7 days from now

You can use UI policy on change request table for this with condition as below:

find_real_file.png

 

find_real_file.pngscript: for execute if true

alert("Please select planned start date within 7 days from now");
g_form.clearValue('planned_start_date'); // use proper field name here

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you!

If you want Business Rule. 

before and insert,update checked

Condition : Planned start date changes or isnot empty 

script

var getPlannedDate = current.start_date;
var dc = new DurationCalculator();
dc.setSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); // this is the sys_id of 8-5 weekday schedule in the instance.
dc.setTimeZone('GMT');
var dur = dc.calcScheduleDuration(gs.now(),getPlannedDate)/3600;
var res = dur.toString();
if(parseInt(res)>= 45){ // Check for  days
gs.addErrorMessage("Please select planned start date within 7 days from now");
current.setAbortAction(true);
}

Regards
Harish

How about if Planned End Date > Planned Start Date?

You have to play a little bit to fine-tune it, but something like below. Then only add your error message in the script.

find_real_file.png

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn