Status depend on date

gy891815
Tera Contributor

If date is past then status will show deployed otherwise it show inprogress in servicenow

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @gy891815 

Not clear with you requirement, but you can try following imaginary script in your BR:

 

(function executeRule(current, previous /*null when async*/) {
var currentDate = new GlideDateTime();
var incidentDate = current.Name_of_date_field;

if (incidentDate <= currentDate) {
    current.incident_status = 'Deployed';
} else {
    current.incident_status = 'In Progress'; 

}

current.setWorkflow(false);
current.update();

current.setWorkflow(true);
})(current, previous);

View solution in original post

7 REPLIES 7

Viraj Hudlikar
Tera Sage

@gy891815 

 

Can you please elaborate your question so we can guide you properly?

If possible do share what you have done so far? Where are you block in this case?

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

Ankur Bawiskar
Tera Patron
Tera Patron

@gy891815 

Are you talking about creating a job or something which checks if the date is in past then update the status?

If yes then where are you stuck?

If not then please share complete details i.e. what's your business requirement along with screenshots.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @gy891815 

 

Why are you creating a duplicate issue?

 

https://www.servicenow.com/community/developer-forum/status-depend-on-date/m-p/3169349/emcs_t/S2h8ZW...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Community Alums
Not applicable

Hi @gy891815 

Not clear with you requirement, but you can try following imaginary script in your BR:

 

(function executeRule(current, previous /*null when async*/) {
var currentDate = new GlideDateTime();
var incidentDate = current.Name_of_date_field;

if (incidentDate <= currentDate) {
    current.incident_status = 'Deployed';
} else {
    current.incident_status = 'In Progress'; 

}

current.setWorkflow(false);
current.update();

current.setWorkflow(true);
})(current, previous);