Help with UI Action and Pop Up Dialog

Charlie Ward
Kilo Expert

I have created a Form Button UI Action called "Place On Hold". Below are the details

Screen Shot 2016-04-28 at 2.03.44 PM.png

Name - Place On Hold

Table - Requested Item [sc_req_item]

Action name - sysverb_hold_and_stay

Active = True

Show insert - False

Show Update - True

Client - False

Form Button - True

Condition - current.canWrite()&&current.state==11&& gs.hasRole("itil")

Script

action.setRedirectURL(current);

current.state=12;

current.update();

I currently have the Sub State field hidden on the request unless the category STARTS WITH "Security > Hardware" and the State is On Hold. I don't want the field on the form any other time. If I have to change something for the below to work, I would need to know how. I'm not sure if you can hard set a field with code if it's not visible on the form.

When the "Place On Hold" button is clicked, I am wanting to have a dialog box pop up that states, "Is the reason you are placing this request on hold because of Awaiting Customer Approval?". Then there would be Yes / No buttons.

If   Yes, then Change state to On Hold, set the Sub State field to Awaiting Customer Approval, update the request and then stay on the current page.

current.state=12;

current.u_sub_state=2;

current.update();

action.setRedirectURL(current);

If No, Change state to On Hold, set the Sub State field on the Requested Item request to None, update the request and then stay on the current page.

current.state=12;

current.u_sub_state=0;

current.update();

action.setRedirectURL(current);

Can anyone help?

Thanks in Advance!

Charlie Ward

Facilities Security and 1CALLNOW Supervisor

University Hospitals Authority & Trust

1 ACCEPTED SOLUTION

Hi Charlie,



I don't have your exact field names and values you want to set, but I hope this would be a good example to how to do it. Let me know if you get stuck.



UI action which calls for the popup window(GlideDialogWindow):



ui page radio button 2.GIF



Then I have made a UI Page called "whyHold" which the UI Action calls on:


I put on 3 radio buttons and two normal(Cancel & OK). pressing cancel just destroys the popup,


Having OK checking which radio button is pressed. There is also a check so if the user doesn't choose a option,


they can't press OK.



ui page radio button.GIF




//Göran


View solution in original post

15 REPLIES 15

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Here is a example of what you can do. If you need more help, just shout


This example pops up a question if I want to set state to awaiting.... and if I press yes, it will do that. otherwise it will cancel


ui action confirm.PNG


HI Goaran,

I have similar requirement like on click ui action "Close task"i have to show popup button with OK and Cancel button i tried below code but its not working cancel button its not aborting please find the below code which i have writen.

var item_name = g_form.getReference('request_item',getName);
function getName(item_name){
var item = item_name.cat_item;
if(item == '33b128013774c3c0ebe32ea843990ee8' || item == '56510103dbdd3b041d398edf4b961978'){
//IT Assets Offboarding Request
if(confirm("please check the hardware status before closing the task")){
gsftSubmit(null, g_form.getFormElement(), 'changeToEditAction');
}
else{
return false;
}

}

 

Kindly help on this 

Regards,

Imam

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Looked a bit closer to your request and think my above solution might not work, since you want different values depending on yes / no.



This will work for you thou 😃



ui action confirm 2.PNG


Goran, thanks for the quick reply.



You have gotten my 90% of the way. This does work, however I'm trying to limit the # of buttons at the top of the form, especially since our technicians are using iPads to process requests so they have limited real estate. I was wanting to have a Place On Hold button that when clicked a dialog pops up asking "Why are you placing this request on hold?" and then below that there would be like 3-5 options for the tech to choose from. I have created a mockup of what I'm looking to do. There are several sub state reasons we are wanting to add to better categorize why something is on hold. I have access controls setup so that the technicians can not change the fields on the form, but rather follow a process via buttons at the top of the form that show according to the state of the request. This way we can automate several processes into one button without having the technician have to remember to go and update 3 different fields and then click save or update.



Please see an example below. When they choose one of the options and then press ok, it will change the state field on the form from Processing or Work In Progress to On Hold, change the sub state field to choice they selected and then saves the record.


Screen Shot 2016-04-29 at 11.17.58 AM.png


Automation is the only way we have been able to keep consistency with communication to the end user because the technicians apparently can't remember all the steps they need to do to update a record. So the less they have to think to do, the better.



I hope this better explains my goal.