Changing assignment group,etc inside iframe isnt working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
21m ago
Hello everyone,
In my workspace, I have a UI action that when pressed the pop up includes a comment field and a dropdown list. When I submit the popup, I expect the following fields to update automatically: Assignment Group, Assigned To, Stage, Work Notes, and Status. The “Assigned To” field should take the value of the user selected from the dropdown in the popup.
However, when I click “OK,” these fields are not updating correctly. Has anyone encountered a similar issue before? What would you recommend as a solution? I’d prefer to keep the current approach rather than changing the overall concept.
Here's m code so far:
My UI Action:
Workspace Client Script:
function onClick(g_form) {
var ticketSysId = g_form.getUniqueValue();
var uiPageSysId = '2d0b6c842145471c60f7603c634663a9';
// Match the OOB parameter structure: sysparm_sysID
var url = '/ui_page.do?sys_id=' + uiPageSysId + '&sysparm_sysID=' + ticketSysId;
g_modal.showFrame({
title: "Finalize Assignment",
url: url,
size: 'lg'
});
}
My UI Page:
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">
<g:ui_form action="ui_page_process.do" id="holool_reassign_form">
<input type="hidden" name="name" value="holool_reassign_form" />
<input type="hidden" id="cancelled" name="cancelled" value="false" />
<g:evaluate jelly="true">
var approved_record = jelly.sysparm_sysID;
</g:evaluate>
<g:evaluate var="jvar_consultants" object="true">
var list = [];
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', '91c95153a8d8475060f7a51d53ae0046');
gr.addQuery('user.active', true);
gr.query();
while (gr.next()) {
list.push({
sys_id: gr.user.toString(),
name: gr.user.getDisplayValue()
});
}
list;
</g:evaluate>
<div style="padding: 15px;">
<div class="form-group">
<label style="font-weight: bold; margin-bottom: 5px;">Assign to Consultant:</label>
<select id="consultant_select" name="consultant_select" class="form-control" style="width: 100%; height: 34px;" required="true">
<option value="">-- Select a Consultant --</option>
<j:forEach items="${jvar_consultants}" var="jvar_user">
<option value="${jvar_user.sys_id}">${jvar_user.name}</option>
</j:forEach>
</select>
</div>
<div class="form-group" style="margin-top: 15px;">
<label style="font-weight: bold; margin-bottom: 5px;">Note to Consultant:</label>
<textarea id="assignment_notes" name="assignment_notes" class="form-control" rows="4" required="true"></textarea>
</div>
<br />
<div class="form-group pull-right" style="margin-right: 15px;">
<g:dialog_buttons_ok_cancel ok="return onSubmit();" cancel="return onCancel();" />
</div>
</div>
<input type="hidden" name="approved_record" id="approved_record" value="${sysparm_sysID}" />
</g:ui_form>
<div class="load_mask_container" style="display: none;">
<span class="icon icon-loading"></span>
</div>
<style>
.load_mask_container {
display: flex;
height: 100%;
width: 100%;
background-color: #ffffff;
position: absolute;
top: 0;
left: 0;
opacity: 0.80;
z-index: 1000;
align-items: center;
justify-content: center;
}
</style>
</j:jelly>
Client Script:
function onSubmit() {
var consultantId = gel('consultant_select').value;
var notes = gel('assignment_notes').value;
if (!consultantId || !notes) {
alert('Please fill out all mandatory fields.');
return false;
}
showLoadMask();
// Force the modern Workspace frame behind the scenes to refresh its layout
setTimeout(function() {
CustomEvent.fire('glide_workspace_refresh_form');
}, 400);
return true;
}
function onCancel() {
var c = gel('cancelled');
c.value = "true";
// Destroys the workspace modal frame overlay natively
if (typeof GlideModalWindow !== 'undefined') {
GlideModalWindow.get().destroy();
} else {
GlideDialogWindow.get().destroy();
}
return false;
}
function showLoadMask() {
var loadMask = document.getElementsByClassName('load_mask_container')[0];
if (loadMask) {
loadMask.style.display = 'flex';
}
}
Processing Script:
if (cancelled == "false") {
// Read the passed variable directly from your input field name
var gr = new GlideRecord('x_nwc_holool_nwc_holool');
gr.addQuery('sys_id', approved_record);
gr.query();
while (gr.next()) {
// 1. Reassign the ticket properties
gr.setValue('assignment_group', '91c95153a8d8475060f7a51d53ae0046'); // Consultants
gr.setValue('assigned_to', consultant_select); // Form field value
// 2. Append the text note content directly into work notes
gr.work_notes = assignment_notes; // Form field value
// 3. Update States & Stages
gr.setValue('state', 2); // Work in progress
var currentStage = gr.getValue('stage');
if (currentStage == '1' || currentStage == 1) {
gr.setValue('stage', 2);
}
// 4. Commit update on the server
gr.update();
// 5. Fire OOB redirect function to stabilize frame callback
redirectToWorkspace();
}
}
function redirectToWorkspace() {
var urlOnStack = "x_nwc_holool_nwc_holool.do?sys_id=" + approved_record;
response.sendRedirect(urlOnStack);
}
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
what's the purpose behind this and not show them the fields on form and ask them to update?
Why the customization?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader