Not able to update the record after saving modal in the workspace
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
I'm getting this error when I open modal and choose a record and save it in the workspace, the actual requirement is to update the current record from where I opened the ui action
function onClick(g_form) {
var ga = new GlideAjax('service');
ga.addParam('sysparm_name', 'getAccount');
ga.addParam('sysparm_service', g_form.getUniqueValue());
ga.getXMLAnswer(function(answer) {
alert(answer);
var taskRecord = g_form.getUniqueValue();
var rawQuery = 'u_account.nameLIKE' + answer +
'^u_configuration_item.ref_service_offering.u_service_class=3rd Party';
var url = 'accounts_list.do?' +
'sysparm_query=' + encodeURIComponent(rawQuery) +
'&sysparm_stack=no' +
'&sysparm_workspace=true' +
'&sysparm_view=popup2' +
'&sysparm_referring_id=' + taskRecord +
'&sysparm_referring_table=incident';
alert('final url' + url);
g_modal.showFrame({
title: 'List of Services',
url: url,
size: 'lg',
height: '22rem',
callback: function() {
g_form.reload();
}
});
});
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
You're already passing sysparm_referring_id and sysparm_referring_table in the URL — use those inside the modal's save script instead of relying on g_form:
// Inside your saveAcc / modal script — extract from URL params, not g_form
var urlParams = new URLSearchParams(window.location.search);
var referringId = urlParams.get('sysparm_referring_id');
var referringTable = urlParams.get('sysparm_referring_table');
Then use a GlideAjax call to update the parent incident server-side:
var ga = new GlideAjax('service');
ga.addParam('sysparm_name', 'updateIncident');
ga.addParam('sysparm_incident_id', referringId);
ga.addParam('sysparm_selected_value', selectedValue);
ga.getXMLAnswer(function(response) {
// close the modal after update
window.parent.postMessage({ action: 'close_modal' }, '*');
});
