- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2025 02:26 PM - edited 03-05-2025 02:27 PM
Hello @mattmg
You can try below Background script to create new Change Request from an existing Change Request to find out whether variables are copied or not.
If there are certain variables to exclude then you can exclude the way I did for sys_id and number.
var grCR = new GlideRecord('change_request');
grCR.get('sys_id'); // enter the sys_id of change request
if (grCR.isValidRecord()) {
var newCR = new GlideRecord('change_request');
newCR.initialize();
for (var key in grCR) {
if (grCR[key] !== undefined && key !== 'sys_id' && key !== 'number') { // Exclude sys_id and number
newCR[key] = grCR[key]; // Copy all values
}
}
newCR.insert();
gs.info('New CR ' + newCR.number);
}
Here is the UI Action Script
if (current.isValidRecord()) {
var newCR = new GlideRecord('change_request');
newCR.initialize();
for (var key in current) {
if (current[key] !== undefined && key !== 'sys_id' && key !== 'number') { // Excluding sys_id and number
newCR[key] = current[key]; // Copy field values
}
}
var newSysId = newCR.insert();
if (newSysId) {
action.setRedirectURL(newCR); // Redirect to the new Change Request
gs.log('New CR# ' + newCR.number);
} else {
gs.addErrorMessage('Failed to create new Change Request.');
}
}
If you want to hide some variables always on the Change Request form then you can have create catalog UI policy on this record producer with only "Applies on the Target Record" as selected and Catalog UI policy actions Visible False for all those Variables which needs to be hidden.
Hope that helps!
Hope that helps!