Script to set incident state to resolved - not working (sets it as "In Progress")

NaturedOne
Giga Contributor

Greetings,

My first post/question on the ServiceNow community, I am currently working with a record producer. The idea here is that as soon as the incident is generated, I want it to be marked as resolved.

Here is my record producer script so far.

current.contact_type = "Walk-in";
current.impact = 4;
current.urgency = 4;
current.priority = 3;
current.u_incident_category = "Desktop Software";
current.u_incident_subcategory = "Support";
current.setDisplayValue("assignment_group","A");
current.short_description = "This is a test";
current.u_closeaction = "Advised";
current.close_code = "Solved (Permanently)";
current.work_notes = "Completed";
current.state = "Resolved";

I double checked that I am setting all of the required fields. I also made sure to set the state to resolved last in my script. If anyone knows why this isn't setting my incident to "Resolved" I'd be very appreciative.

1 ACCEPTED SOLUTION

rahulpandey
Kilo Sage
Hi, Did you try setting the choice value (like 6) instead of word Resolved.

View solution in original post

4 REPLIES 4

rahulpandey
Kilo Sage
Hi, Did you try setting the choice value (like 6) instead of word Resolved.

Alikutty A
Tera Sage

Hello,

This is because of the Resolved Label as mentioned by Rahul, Also close notes was mandatory when i checked OOB.

Maybe you should try changing both if the state change didnt work

current.state = 6;

current.close_notes ='Test';

Thanks

This is a great suggestion. My close notes are actually mapped by the record producer field I created so I don't have them in the script but the data is in fact there. I will try your suggestion for current.state and report back.

NaturedOne
Giga Contributor

Thanks guys, you were totally right, I needed to set it to

current.state = 6;

instead of

current.state = "Resolved";