Workspace UI Actions with Popup Dialogs for Parent Record Field Mapping in Child Record Creation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 01:03 AM
Introduction:
In ServiceNow, creating child records often involves manual data entry, which can be time-consuming and prone to errors. However, by leveraging Workspace UI Actions with Popup Dialogs, we can streamline this process by mapping parent record fields to child records efficiently. In this article, we'll explore how to implement this functionality, improving productivity and accuracy within the ServiceNow platform.
UI Action:
Client : true
Onclick:
Script:
// Code that runs without 'onclick'
// Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
createLog();
// Server-side function
function createLog() {
var ChangeGr = new GlideRecord('change_request');
ChangeGr.initialize();
ChangeGr.short_description = current.short_description;
ChangeGr.description = current.description;
ChangeGr.parent = current.sys_id;
ChangeGr.cmdb_ci = current.cmdb_ci;
ChangeGr.u_software = current.u_software_pkg;
ChangeGr.start_date = current.sys_created_on;
// Map the required fields
ChangeGr.insert();
action.openGlideRecord(ChangeGr);
}
Workspace Form Button: true
Format for Configurable workspace : true
Workspace Client Script:
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'u_software_pkg',
label: getMessage('Please select the Software and Version'),
mandatory: true,
reference: 'cmdb_ci_spkg',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue(),
value: g_form.getValue('u_software_pkg'),
displayValue: g_form.getDisplayValue('u_software_pkg')
}];
g_modal.showFields({
title: "Software",
instruction: getMessage('Please choose "Generic CI" from the dropdown menu if this does not qualify as a software change log.'),
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('u_software_pkg', fieldValues.updatedFields[0].value);
g_form.submit('create_log');
g_form.save();
});
}
By following these steps and customising the code to fit your specific requirements, you can empower users to create child records seamlessly while ensuring data consistency and reliability within your ServiceNow environment.
- 729 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 01:20 AM
Thanks @Sandhya Gurram Very Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 11:42 PM
Very Helpful article
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2024 11:45 PM
Very Helpful!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2024 10:57 PM
Thanks @Sandhya Gurram , it really helps