UI Page not rendering when passing parameters from UI action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 02:33 AM
Hi
I have a UI action (client with Onclick) on Incident, in which I am trying to pass the SysId and CI to a UI page. However, the dialog window does not render unless I remove the "dialog.addParam" lines
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2023 05:19 AM
@Ankur Bawiskar If you mean the ui action script I have already done so but it still doesn't open.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2023 11:13 PM
this UI action script is fine.
I am referring that you should be able to get the values of those 2 fields to UI page and then you can proceed in UI page script
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 12:59 AM
I was able to retrieve and set the value using this script:
function onLoad() {
console.log("onLoad event fired");
// Retrieve the sys_id from URL parameters
var urlParams = new URLSearchParams(window.location.search);
var sysId = urlParams.get('sys_id');
console.log("sysId:", sysId);
// Create a new instance of GlideRecord
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', sysId);
gr.query();
if (gr.next()) {
var fieldValue = gr.getValue('number');
console.log("Matching Record Found:", fieldValue);
// Set the value of the 'incident' field directly
document.getElementById('incident').value = fieldValue;
console.log("Field value set:", document.getElementById('incident').value);
// Set the value of the 'incident' field using a callback function
g_form.addInfoMessage('Setting field value...');
g_form.setValue('incident', fieldValue);
console.log("Field value set:", g_form.getValue('incident'));
} else {
console.error("Incident record not found with sys_id:", sysId);
}
}
// The onLoad() function will be automatically invoked when the page loads
onLoad();
The console logs confirm this is successful but the incident field is not populated the the page loads
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 02:00 AM
what is this line doing?
g_form.setValue('incident', fieldValue);
also you are not updating the record using gr object
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2023 02:45 AM
@Ankur Bawiskar it appears to set the value but doesn't display it when the page loads - here are the logs which confirm the value is set
onLoad event fired
VM27475:8 sysId: 05c307621bdea510349f40c4e34bcb9d
js_includes_doctype.jsx?v=05-15-2023_1848&lp=Tue_Jun_13_03_16_55_PDT_2023&c=8_102:870 [00:00:00.079] *** WARNING *** GlideAjax.getXMLWait - synchronous function - processor: AJAXGlideRecord
js_includes_doctype.jsx?v=05-15-2023_1848&lp=Tue_Jun_13_03_16_55_PDT_2023&c=8_102:16858 *** WARNING *** GlideAjax.getXMLWait - synchronous function - processor: AJAXGlideRecord
js_includes_doctype.jsx?v=05-15-2023_1848&lp=Tue_Jun_13_03_16_55_PDT_2023&c=8_102:870 [00:00:00.081] *** WARNING *** GlideRecord synchronous query for table: incident
VM27475:17 Matching Record Found: INC0117518
VM27475:21 Field value set: INC0117518
VM27475:26 Field value set: INC0117518
I am not updating the record at this point - I have a continueOK() script which updates the relevant record when the ui page is submitted.