The CreatorCon Call for Content is officially open! Get started here.

How to set incident state is "WIP" automatically

akin9
Tera Contributor

Hello expets

We have requirment.

 

We have a field is  Due date.  If below conditions are met field will be visible. or else Hide.

akin9_0-1668519746116.png

 

Requirement is 

Incident should switch back to WIP as soon as the set date/time is reached.

Please support to achieve this

16 REPLIES 16

@Ankur Bawiskar ,

Thank you for your Quick reply ,

My Current time is - 12.52  IST.

Postpone shedule - 022-11-16 12:48:00

Sry ! i tried above code but unfortunately not working. Please correct me if any wrong.

This is the requirment msg from my client.FYI.

akin9_1-1668583596574.png

 

akin9_0-1668583392088.png

 

Thank you

@akin9 

I already told you can write script but testing will be tricky as you should open the form at the exact second which is present in date/time field.

Script I shared will work fine but testing is difficult.

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

Hi@Ankur Bawiskar,

Once again Thank very much for your Quick reply and support!

Hi@Ankur Bawiskar,

Sry for disturbing again!.

I was looking some articles in community i got a clue using scheduled job we can achieve our requirment.

able-"incident"

field name - "u_postpone_schedule"

In Progress value - "2"

On Hold value - "3"

state - "state "

so i tried below code but not working can u help me on this.

NoTE:Based on date need to change the state from ON Hold to IN PROGRESS " Time no need to consider.

var gr = new GlideRecord("incident");
gr.addActiveQuery();
gr.query();
var today = new GlideDateTime().getDate();
while(gr.next()) {
var postpone = gr.getValue("u_postpone_schedule");
var gdt = new GlideDateTime(postpone);
if(gdt.on(today)) {
gr.state=2;
gr.update();
}
}

 

Please correct me

Thank you!

@akin9 

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