Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

On change request, planned start date should always be 24 hours ahead of current time.

prabhmeet
Giga Expert

 Hi,

I am new to ServiceNow and still learning. Can anyone help me with this requirement- On change request, planned start date should always be 24hrs ahead of current time.

I do not know how to do this. I hope someone can help.

1 ACCEPTED SOLUTION

Narendra Kota
Mega Sage

Hi,

you can write a before insert, update business rule.

Condition: current.planneddatefield.changes()

Script:

(function executeRule(current, previous /*null when async*/) {

if(current. planneddatefield<= gs.daysAgo(-1)) {

current.setAbortAction(true);

gs.addInfoMessage("The planned start date must be more than 1 calendar days in the future.");
}

})(current, previous);

 

Mark my answer as correct or helpful if it helped.

View solution in original post

5 REPLIES 5

Narendra Kota
Mega Sage

Hi,

you can write a before insert, update business rule.

Condition: current.planneddatefield.changes()

Script:

(function executeRule(current, previous /*null when async*/) {

if(current. planneddatefield<= gs.daysAgo(-1)) {

current.setAbortAction(true);

gs.addInfoMessage("The planned start date must be more than 1 calendar days in the future.");
}

})(current, previous);

 

Mark my answer as correct or helpful if it helped.

Thanks, this is working.

Hi Narendra,

if I have to write a client script, how can I do that?

Ian Mildon
Tera Guru

Are you wanting to inform users of this requirement, or are you wanting to actual set the date automatically?