- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-28-2016 12:09 PM
I have created a Form Button UI Action called "Place On Hold". Below are the details
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()&¤t.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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2016 02:50 PM
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):
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.
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 07:47 AM
Hi Brian,
On gsftsubmit , it should be your UI action name for eg order_cancel is my UI action name so i called that it gsftsubmit
gsftSubmit(null, g_form.getFormElement(), 'order_cancel'); // MUST call the 'Action name' set in this UI Action
If you are still confused please attach screenshot of complete UI Action including names
Thanks,
Divya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 08:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 11:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 12:05 PM
Brian,
Also from the screenshot, I observed few
1. gsft statement under if also needs to have your action name gsftSubmit(gel('[Action Name]');
2. validateComments() function is not called anywhere
3. Is HTML and Client script part of UI Action? I dont see any kind of HTML or client scripts on UI action form in my instance
Correct those and it should work
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-03-2021 01:29 PM
Hi Divya,
This is my 4 days of learning ServiceNow. If you could please provide me with the exactly codes in UI Action, HTML, Client Script containers so that I can take a look and try to understand how each piece are working together. That would be very helpful for my future SN project. Than you so much Divya!
Here are my current codes for UI Action, HTML and Client Script:
UI Action:
function doConfirm(){
var gdw = new GlideDialogWindow('whyHold2');
gdw.setTitle('Why Why?');
gdw.setSize(750,300);
gdw.render(0);
}
HTML in UI Page
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Please choose the reason you are placing this request On hold.
<form id="myForm">
<input type="checkbox" name="checkboxName" value="1"/>Awaiting Customer Approval<br/>
<input type="radio" name="radioName" value="2"/>Parts On Order<br/>
<input type="radio" name="radioName" value="3"/>Other<br/>
</form>
<button id="cancelpage" onclick="cancelPage();">Cancel</button>
<button id="okpage" onclick="okPage();">OK</button>
</j:jelly>
Client Script in UI Page
function okPage() {
var choices = document.getElementsByName("radioName");
var answer = '';
for (var i = 0; i < choices.length; i++) {
if (choices[i].checked) {
answer = choices[i].value;
break;
}
}
if (answer == '')
return false;
GlideDialogWindow.get().destroy();
// g_form.setValue('short_description', answer);
g_form.setValue("work_notes", answer);
// gsftSubmit(gel('sysverb_update_and stay'));
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
}
function cancelPage() {
GlideDialogWindow.get().destroy();
}