Skip to content

Commit 8a17d38

Browse files
Create Copy Variable Set.xml
Copy any Variable Set
1 parent ce6066c commit 8a17d38

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
This XML file does not appear to have any style information associated with it. The document tree is shown below.
2+
<unload unload_date="2023-06-16 10:43:05">
3+
<sys_ui_action action="INSERT_OR_UPDATE">
4+
<action_name>copy_variable_set</action_name>
5+
<active>true</active>
6+
<client>false</client>
7+
<client_script_v2>
8+
<![CDATA[ function onClick(g_form) { } ]]>
9+
</client_script_v2>
10+
<comments/>
11+
<condition/>
12+
<form_action>true</form_action>
13+
<form_button>true</form_button>
14+
<form_button_v2>false</form_button_v2>
15+
<form_context_menu>false</form_context_menu>
16+
<form_link>false</form_link>
17+
<form_menu_button_v2>false</form_menu_button_v2>
18+
<form_style/>
19+
<format_for_configurable_workspace>false</format_for_configurable_workspace>
20+
<hint/>
21+
<isolate_script>false</isolate_script>
22+
<list_action>false</list_action>
23+
<list_banner_button>false</list_banner_button>
24+
<list_button>false</list_button>
25+
<list_choice>false</list_choice>
26+
<list_context_menu>false</list_context_menu>
27+
<list_link>false</list_link>
28+
<list_save_with_form_button>false</list_save_with_form_button>
29+
<list_style/>
30+
<messages/>
31+
<name>Copy Variable Set</name>
32+
<onclick/>
33+
<order>100</order>
34+
<script>
35+
<![CDATA[ //set some new default values var setName = current.title; current.title = 'Copy of ' + setName; current.sys_scope = gs.getCurrentApplicationId(); current.sys_policy = ""; //insert a copy of the variable set var oldid = current.sys_id.toString(); var newid = current.insert(); if (newid) { var allVars = {}; createVariables(oldid, newid); createCatalogClientScript(oldid, newid); createCatalogUiPolicy(oldid, newid); } //creates a copy of the variables and associates them to the new variable set function createVariables(oldid, newid) { var vars = new GlideRecord('item_option_new'); vars.addQuery('variable_set', oldid); vars.addActiveQuery(); vars.query(); while (vars.next()) { var varoldid = vars.sys_id.toString(); vars.variable_set = newid; var varnewid = vars.insert(); allVars['IO:' + varoldid] = 'IO:' + varnewid.toString(); var qc = new GlideRecord('question_choice'); qc.addQuery('question', varoldid); qc.query(); while (qc.next()) { qc.question = varnewid; qc.insert(); } } } //creates a copy of the client scripts and associates to the variable set. function createCatalogClientScript(oldid, newid) { var ccs = new GlideRecord('catalog_script_client'); ccs.addQuery('variable_set', oldid); ccs.addActiveQuery(); ccs.query(); while (ccs.next()) { ccs.variable_set = newid; ccs.insert(); } } //creates a copy of the UI Policies and associates them to the new variable set function createCatalogUiPolicy(oldid, newid) { var cup = new GlideRecord('catalog_ui_policy'); cup.addQuery('variable_set', oldid); cup.addActiveQuery(); cup.query(); while (cup.next()) { var uipoldid = cup.sys_id.toString(); cup.variable_set = newid; var newuip = cup.insert(); var cupa = new GlideRecord('catalog_ui_policy_action'); cupa.addQuery('ui_policy', uipoldid); cupa.query(); while (cupa.next()) { cupa.ui_policy = newuip; cupa.variable_set = newid; var cv = cupa.catalog_variable; cupa.catalog_variable = allVars[cv]; cupa.insert(); } } } //Return the user to the new variable set record action.setRedirectURL(current); ]]>
36+
</script>
37+
<show_insert>true</show_insert>
38+
<show_multiple_update>false</show_multiple_update>
39+
<show_query>false</show_query>
40+
<show_update>true</show_update>
41+
<sys_class_name>sys_ui_action</sys_class_name>
42+
<sys_created_by>DHR9657</sys_created_by>
43+
<sys_created_on>2022-03-07 07:33:19</sys_created_on>
44+
<sys_domain>global</sys_domain>
45+
<sys_domain_path>/</sys_domain_path>
46+
<sys_id>cd0ad092dbc2051005edd9fcd396195a</sys_id>
47+
<sys_mod_count>8</sys_mod_count>
48+
<sys_name>Copy Variable Set</sys_name>
49+
<sys_overrides display_value=""/>
50+
<sys_package display_value="Global" source="global">global</sys_package>
51+
<sys_policy/>
52+
<sys_scope display_value="Global">global</sys_scope>
53+
<sys_update_name>sys_ui_action_cd0ad092dbc2051005edd9fcd396195a</sys_update_name>
54+
<sys_updated_by>admin</sys_updated_by>
55+
<sys_updated_on>2023-06-16 10:42:52</sys_updated_on>
56+
<table>item_option_new_set</table>
57+
<ui11_compatible>true</ui11_compatible>
58+
<ui16_compatible>false</ui16_compatible>
59+
</sys_ui_action>
60+
</unload>

0 commit comments

Comments
 (0)