UI action button to create a problem based on the state of incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2017 04:12 AM
Hi Team
I am creating the UI action button for creating the problem. Here I have the requirement like whenever anyone clicks on the create problem button if the state of an incident is closed or resolved it has to redirect to the problem table else it has to show the alert like the state needs to be closed or resolved.
Please help me with step by step process as I am very new to this development.
Best Regards
Sreedhar
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2017 08:27 AM
Hi
one quick question.
if we talk about ITIL process we create problem once we are not able to fix it via change request,
the process will like Incident>Change>Problem.
by the way coming to your requirement
there is already Out of the box Ui Action exist in servicenow and if you want to make it visible based on state value then put
current.state==6 || current.state==7 in ui action condition field.
System Definition >> UI Actions then search for Create Problem
this ui action is Form Context Menu type. if you want this on your right side of the form then check "Form Button" check box in this UI ACtion.
check the screenshot below.
https://<your instance>.service-now.com/sys_ui_action.do?sys_id=2f43c471c0a8006400a07440e49924c2&sysparm_view=&sysparm_record_target=&sysparm_record_row=1&sysparm_record_list=nameSTARTSWITHcreate+problem%5EORDERBYorder&sysparm_record_rows=1
I have another question that you had mentioned when ever the state will be closed or resolved you want to redirect it on problem table but you need to click on the button and it will automatically redirect to the problem page.
Now coming to alert part> if you will not make the state to Closed or resolved the button will not appear on the form. so in-short you must need to make the state value to either close or resolved, i think you don't need alert for it .
Let me know if it does not help
Thanks,
Harshvardhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2017 02:47 AM
HI Harsha,
Have written the same condition which you have mentioned.
current.state==6 || current.state==7
And had written the code like
function createproblem()
{
var st = g_form.getValue('state');
if(st==6 || 7){
var gr = new GlideRecord('problem');
gr.initialize();
gr.short_description= current.short_description;
gr.insert();
}
else {
alert('if you want to create problem state resolved or closed');
action.setRedirectURL(current);
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'create_prob');
}
if(typeof window == 'undefined')
runBusRuleCode();
function rudBusRuleCode(){
current.state = 2;
current.update();
current.setRedirectURL(current);
}
You asked about the button visibility right, The button should be in the visible form when the end user clicks on that button if the state is closed or resolved then it has to allow the user to create problem else it has to show an alert.
Best Regards
Sreedhar