
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2019 10:16 AM
I have a UI action and page that I am trying to customise based on a category selected.
The ui action sets a field as mandatory and asks the user to complete. When ui action pressed again, it calls a dialog box to add comments.
I have read through: https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
but as it uses the dialog, I need the client side of the ui page to submit the changes made to the new mandatory field on the form. However, when pressing ok on the dialog, it prompts me to leave page so the changes made are not saved.
The client script on the ui page is as follows:
function submitCancel() {
$("button_clicked").value = 'cancel';
$("hr_comment").value = '';
GlideDialogWindow.get().destroy();
return false;
}
function submitOk() {
var comments = gel("hr_comment").value;
comments = trim(comments);
if (comments == "") {
//If comments are empty stop submission
alert("Please provide comments.");
return false;
}
$('cancel_button').addClassName('disabled');
$('ok_button').addClassName('disabled');
g_form.save();
return true;
}
function formFieldsValid() {
return ($("hr_comment").value != '');
}
The processing script is:
(function(_this) {
if (button_clicked == 'ok') {
// Write the reason into task journal
var task = new GlideRecord(task_table);
task.addQuery('sys_id', task_sys_id);
task.query();
task.setWantSessionMessages(false);
task.next();
if (is_comment == "true"){
task.comments = hr_comment;
gsftSubmit(document.getElementById('sysverb_update_and_stay'));
}
else
task.work_notes = hr_comment;
if (is_close == "true")
task.close_notes = hr_comment;
if (state_sys_id != '') {
// Move the State flow
new StateFlow().processFlow(task, state_sys_id, 'manual');
}
if (dialog_type == 'escalate_case') {
var manager = task.assignment_group.manager;
var group = new GlideRecord('sys_user_grmember');
group.addQuery('group', task.assignment_group);
group.addQuery('user', manager);
group.query();
group.setWantSessionMessages(false);
if (manager == '') {
gs.addErrorMessage(gs.getMessage('{0} could not be reassigned because assignment group manager was not found.', task.number));
} else if (!group.hasNext()) {
gs.addErrorMessage(gs.getMessage('{0} could not be reassigned because assignment group manager is not a member of the group.', task.number));
} else {
task.assigned_to = manager;
task.update();
gs.addInfoMessage(gs.getMessage('{0} was reassigned to {1}.', [ task.number, task.assignment_group.manager.name ]));
}
}
var url;
if (state_sys_id != '')
url = task_table + '.do?sys_id=' + task.sys_id;
else
url = GlideSession.get().getStack().bottom();
response.sendRedirect(url);
}
})(this);
I have reviewed
https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/
https://www.servicenowguru.com/system-ui/glidedialogwindow-quickforms/
but neither point me in the right direction.
Please help
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2019 06:07 AM
Hi Ankur, I spoke to Hi about this as even with the log statements, it wasnt achievable to do what I wanted.
Ultimately, the comment ui box is updating rather than saving so I would need to rebuild or just abort what I was trying to build.
I am now leaving it alone so no further help is required at this stage.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 12:47 AM
Hi Matt,
So basically you are calling UI page from UI action; there some input text box is there and user will enter some value in it; from the UI page itself you want the form to be saved
is the button_clicked hidden html value being set; if yes then only it will execute the processing script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 12:58 AM
Hi Ankur,
Yes, the UI action is calling the UI page and prompting the user to enter comments. When the comments are added and the user presses ok, then it adds the comments to the close notes and comments/worknotes. I also need it to save any changes that have been made by the user prior to pressing the UI action. However, this is not happening.
This is the HTML I have for the button_clicked:
<input type="hidden" id="button_clicked" name="button_clicked" value="ok"></input>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2019 01:12 AM
Hi Matt,
Did you try adding log statements in the processing script?
also try to add try catch block to know any exception is to be handled or not
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2019 04:10 AM
Hi Matt,
Any update on this?
Can you mark my answer as ✅ correct, 👍 helpful if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader