Stop New Incident Record Cannot be Resolved

Jacob23
Mega Guru

Hi, I am trying to setup some logic to stop users from opening a new incident record and then closing it as resolved. We want a new incident record to only be open as "New" or In "Progress". Happy to either stop the State field from showing the options in the first place until ticket has been moved to "In Progress", or create a field alert to let them know it cannot be set as resolved from a new state.

I would like assistance with the script that would need to be used within an on client script. I could aslo do via a busienss rule but that will require the users to fill out the form and submit the ticket for the error to bounce back.

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

You can do this via an Onload script on the incident table with something like this: 

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.clearOptions('state');
		g_form.addOption('state', '1', 'New');
		g_form.addOption('state', '2', 'In Progress');
    }

}

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

8 REPLIES 8

I would suggest using the State Flows table Use state flows.  You would just create the records where the states can move from new and so on 

find_real_file.png

Thanks,

David Whaley

Thanks for raising this, I have not seen this before but good to know for future reference. I am happy with the solution I currently have in place.

Gunjan Kiratkar
Kilo Patron
Kilo Patron

 

Hi Jacob, 

 

You can use below change client script which will work both onChange and onLoad :- Remove choices as per your requirement.:-  On Change of state

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
if (g_form.getValue('state') == 1) {
g_form.removeOption('state', '3');
g_form.removeOption('state', '6');
g_form.removeOption('state', '7');
g_form.removeOption('state', '8');
}
return;
}

//Type appropriate comment here, and begin script below
if (newValue == 2) {
g_form.addOption('state', '1','New',1);
g_form.addOption('state', '2','In Progress',2);
g_form.addOption('state', '3','On Hold',3);
g_form.addOption('state', '6','Resolved',4);
g_form.addOption('state', '7','Closed',5);
g_form.addOption('state', '8','Canceled',6);
}


}

 

 

Please mark my answer as helpful/correct if it resolves your query.

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Output:-

New Incident:-

find_real_file.png

 

When the state moves to in progress:-

find_real_file.png


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy