How to set incident state is "WIP" automatically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 05:44 AM
Hello expets
We have requirment.
We have a field is Due date. If below conditions are met field will be visible. or else Hide.
Requirement is
Incident should switch back to WIP as soon as the set date/time is reached.
Please support to achieve this
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 09:39 PM
Glad to help.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:10 PM
Thanks for motivating me!
I tried with below code but unfortunately not working properly.
function onLoad() {
//Type appropriate comment here, and begin script below
var postpone = g_form.getValue('u_postpone_schedule');
var ajax = new GlideAjax('date/timeToday');
ajax.addParam('sysparm_name', 'date/timeToday');
ajax.addParam('sysparm_postpone', postpone);
ajax.getXMLWait();
var answer = ajax.getAnswer();
g_form.setValue('state', 2);
}
Issue is normally state is in on hold.
But after opening only the incident it is changed to InProgress
But my requirment is if Postpone date is reached then incident should be switch to inprogress automatically.
or else we can achieve this by any Before/after BR?
Plesae help me on this ,
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 10:32 PM
you can use Display business rule on incident table and check this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var nowTime = new GlideDateTime();
var postpone = new GlideDateTime(current.u_postpone_schedule);
if(nowTime.getNumericValue() == postpone.getNumericValue())
g_scratchpad.isDateReached = 'true';
else
g_scratchpad.isDateReached = 'false';
})(current, previous);
onLoad client script
function onLoad(){
if(g_scratchpad.isDateReached == 'true')
g_form.setValue('state', 2);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:06 PM
Thank you for your Quick reply ,
i tried above code but unfortunately not working. Please correct me if any wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2022 11:10 PM
what's your current time and what's the time in that field?
date is same but time should also be same -> but it would be very difficult since time has seconds also in it
try this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var nowTime = new GlideDateTime();
var postpone = new GlideDateTime();
postpone.setDisplayValue(current.u_postpone_schedule):
if(nowTime.getNumericValue() == postpone.getNumericValue())
g_scratchpad.isDateReached = 'true';
else
g_scratchpad.isDateReached = 'false';
})(current, previous);
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader