On Hold UI Action in SOW with mandatory Reason

GraceFi
Tera Contributor

Hi all,

 

I have the request to add a button "Put On Hold" on top of the incident form within the SOW. When clicking it, the agent should choose a Reason and then submit it. The incident should then be put on hold with the correct reason.

 

I found this post https://www.servicenow.com/community/developer-forum/help-with-ui-action-and-pop-up-dialog/m-p/21549... where a pop up dialog is implemented and I wrote the code accordingly. But it doesn't work. Can anyone help me?

GraceFi_0-1718180419837.png

 

GraceFi_0-1718180707903.png

 

additionally, i want to add to the on hold reason the mandatory comment field that has to be filled out by the agent in order to put it on hold.

 

Thanks in advance!

1 REPLY 1

acherie
Tera Contributor

Hi GraceFi,

I think the type is the issues.

The following screenshots code works for me

HTML:

<?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="radio" name="hold_reason" value="1"/>Awaiting Caller<br />
<input type="radio" name="hold_reason" value="3"/>Awaiting Problem<br />
<input type="radio" name="hold_reason" value="4"/>Awaiting <br />
<input type="radio" name="hold_reason" value="5"/>Awaiting Vendor<br />
</form>
  <button id="cancelpage" onclick="cancelPage();"> Cancel </button>
  <button id="okpage" onclick="okPage();"> Ok </button>

</j:jelly>
Client script:
function okPage() {
    var choices = document.getElementsByName("hold_reason");
    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("hold_reason", answer);
    g_form.setValue("state", 3);
    gsftSubmit(gel("sysverb_update_and_stay"));

}

function cancelPage() {
    GlideDialogWindow.get().destroy();

}
UI action:
function onHold() {
    var gdw = new GlideDialogWindow('whyHold');
    gdw.setTitle('Why');
    gdw.setSize(750, 300);
    gdw.render();
}