- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2025 11:27 AM
Is it possible to copy UI policy actions to another UI Policy?
I have a situation where the UI policies I have are fairly complex and the UI policies are against the same items but I just need to change visiblity/etc. and having to manually recreate like 15 items per action is a total pain.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2025 02:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2025 03:28 PM
explain?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2025 11:08 AM
@bigbacon Open the UI Policy that you want to copy the UI Policy Actions from. Click on the hamburger menu and then select Insert with Actions. This will create a duplicate of your UI Policy record, and will also copy over the UI Policy Actions, and then you can modify the new record to meet your needs.
My screenshot shows this with a Catalog UI Policy, but it works with regular UI Policies too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 04:36 PM
Works! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2025 05:25 PM
hi @bigbacon
Yes, it is possible to copy UI Policy Actions from one UI Policy to another in ServiceNow, but there's no built-in button or feature in the UI to do it directly. You'll need to use a couple of different methods to achieve this:
Methods to Copy UI Policy Actions
1. Using Background Scripts (Most Efficient for Bulk Copying)
This method is best if you have many UI Policy Actions to copy or need to repeat this process multiple times.
(function copyUIPolicyActions() {
var sourceUIPolicySysId = 'YOUR_SOURCE_UI_POLICY_SYS_ID'; // Replace with the sys_id of your source UI Policy
var targetUIPolicySysId = 'YOUR_TARGET_UI_POLICY_SYS_ID'; // Replace with the sys_id of your target UI Policy
// Get the source UI Policy Actions
var sourceActions = new GlideRecord('sys_ui_policy_action');
sourceActions.addQuery('ui_policy', sourceUIPolicySysId);
sourceActions.orderBy('order'); // Maintain the original order
sourceActions.query();
while (sourceActions.next()) {
// Create a new UI Policy Action for the target UI Policy
var targetAction = new GlideRecord('sys_ui_policy_action');
targetAction.initialize();
// Copy relevant fields (adjust as needed based on your requirements)
targetAction.ui_policy = targetUIPolicySysId;
targetAction.field_name = sourceActions.field_name;
targetAction.clears_value = sourceActions.clears_value;
targetAction.mandatory = sourceActions.mandatory;
targetAction.visible = sourceActions.visible;
targetAction.read_only = sourceActions.read_only;
targetAction.order = sourceActions.order;
targetAction.script_false = sourceActions.script_false; //if copying the script
targetAction.script_true = sourceActions.script_true; //if copying the script
// Insert the new action
targetAction.insert();
}
gs.print('UI Policy Actions copied successfully!');
})();
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer🌠 OR mark it Helpful ⛑ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2025 05:29 PM
hi @bigbacon
If you are feel uncomfortable with script then the other strategy Action &Stay
If you only have a few UI Policy Actions to copy, you can do it manually using the "Insert and Stay" functionality:
Open the Source UI Policy: Go to the UI Policy record from which you want to copy actions.
Open the UI Policy Actions List: In the "UI Policy Actions" related list, right-click the header and choose "Open in New Window".
Open the Target UI Policy: Open the target UI Policy where you want to add the copied actions.
Go to the Source UI Policy Actions List: In the newly opened window, select the first UI Policy Action you want to copy.
Change the "UI Policy" field to your target UI Policy.
Make sure the table/view where the target UI Policy will apply has the field that is defined in the UI Policy Action. If not, change the field name or create it in the table/view.
Adjust any other necessary fields, like "Order".
Right-click the header and select "Insert and Stay": This will create a copy of the action and keep you on the same form.
Repeat steps 5-6: Modify the fields for the target UI Policy and use "Insert and Stay" for each action you want to copy.