<?xml version="1.0" encoding="UTF-8"?><unload unload_date="2021-12-09 07:24:27">
<sys_remote_update_set action="INSERT_OR_UPDATE">
<application display_value="Global">global</application>
<application_name>Global</application_name>
<application_scope>global</application_scope>
<application_version/>
<collisions/>
<commit_date/>
<deleted/>
<description>This is an Add-on to DCM application. Supports to create cross-scope application access, required by DCM app, for tables referenced in available relationships and available classes.</description>
<inserted/>
<name>DCM Addon Util - Cross scope privilege creator v2.3</name>
<origin_sys_id/>
<parent display_value=""/>
<release_date/>
<remote_base_update_set display_value=""/>
<remote_parent_id/>
<remote_sys_id>1cbcc3791b104110d90ae1db234bcb27</remote_sys_id>
<state>loaded</state>
<summary/>
<sys_class_name>sys_remote_update_set</sys_class_name>
<sys_created_by>ab@dcm.fi</sys_created_by>
<sys_created_on>2021-12-09 07:24:26</sys_created_on>
<sys_id>212d43791b104110d90ae1db234bcb44</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>ab@dcm.fi</sys_updated_by>
<sys_updated_on>2021-12-09 07:24:26</sys_updated_on>
<update_set display_value=""/>
<update_source display_value=""/>
<updated/>
</sys_remote_update_set>
<sys_update_xml action="INSERT_OR_UPDATE">
<action>INSERT_OR_UPDATE</action>
<application display_value="Global">global</application>
<category>customer</category>
<comments/>
<name>sys_ui_action_3bf8aaad4f93230058224e318110c77f</name>
<payload>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;record_update sys_domain="global" table="sys_ui_action"&gt;&lt;sys_ui_action action="INSERT_OR_UPDATE"&gt;&lt;action_name/&gt;&lt;active&gt;true&lt;/active&gt;&lt;client&gt;true&lt;/client&gt;&lt;client_script_v2&gt;&lt;![CDATA[function onClick(g_form) {

}]]&gt;&lt;/client_script_v2&gt;&lt;comments&gt;creats cross scope privilege entries&lt;/comments&gt;&lt;condition&gt;gs.getProperty('x_jugr_dcm.app_exist')==='true'?gs.hasRole("admin"):false&lt;/condition&gt;&lt;form_action&gt;true&lt;/form_action&gt;&lt;form_button&gt;true&lt;/form_button&gt;&lt;form_button_v2&gt;false&lt;/form_button_v2&gt;&lt;form_context_menu&gt;false&lt;/form_context_menu&gt;&lt;form_link&gt;false&lt;/form_link&gt;&lt;form_menu_button_v2&gt;false&lt;/form_menu_button_v2&gt;&lt;form_style/&gt;&lt;hint/&gt;&lt;isolate_script&gt;false&lt;/isolate_script&gt;&lt;list_action&gt;true&lt;/list_action&gt;&lt;list_banner_button&gt;false&lt;/list_banner_button&gt;&lt;list_button&gt;false&lt;/list_button&gt;&lt;list_choice&gt;true&lt;/list_choice&gt;&lt;list_context_menu&gt;false&lt;/list_context_menu&gt;&lt;list_link&gt;false&lt;/list_link&gt;&lt;list_save_with_form_button&gt;false&lt;/list_save_with_form_button&gt;&lt;list_style/&gt;&lt;messages/&gt;&lt;name&gt;Set Up Scope Access for DCM&lt;/name&gt;&lt;onclick&gt;openCrossScopeCreateModal()&lt;/onclick&gt;&lt;order&gt;100&lt;/order&gt;&lt;script&gt;&lt;![CDATA[function openCrossScopeCreateModal(){
	var dialog = new GlideModal("dcm_csp_create_dialog");
    dialog.setTitle("Confirm Cross-Scope Access");
	dialog.setPreference("sys_id_list", getSysIdList());
	dialog.setPreference("table_name", getTableName());
	dialog.render();	
}

function getTableName(){
	if(window.g_list){
		return g_list.getTableName();
	}else if(window.g_form){
		return g_form.getTableName();
	}
}

function getSysIdList(){
	if(window.g_list &amp;&amp; (typeof g_sysId == "undefined" || !g_sysId)){
		
		return  g_list.getChecked();
	}else if(window.g_sys_id &amp;&amp; !window.g_form){
		// only row id on which context menu opened
		// rowSysId is legacy
		return g_sysId;
	}else if(window.g_form){
		return g_form.getUniqueValue();
	}		
}]]&gt;&lt;/script&gt;&lt;show_insert&gt;false&lt;/show_insert&gt;&lt;show_multiple_update&gt;false&lt;/show_multiple_update&gt;&lt;show_query&gt;false&lt;/show_query&gt;&lt;show_update&gt;true&lt;/show_update&gt;&lt;sys_class_name&gt;sys_ui_action&lt;/sys_class_name&gt;&lt;sys_created_by&gt;ab@justin.fi&lt;/sys_created_by&gt;&lt;sys_created_on&gt;2019-01-29 12:10:33&lt;/sys_created_on&gt;&lt;sys_domain&gt;global&lt;/sys_domain&gt;&lt;sys_domain_path&gt;/&lt;/sys_domain_path&gt;&lt;sys_id&gt;3bf8aaad4f93230058224e318110c77f&lt;/sys_id&gt;&lt;sys_mod_count&gt;4&lt;/sys_mod_count&gt;&lt;sys_name&gt;Set Up Scope Access for DCM&lt;/sys_name&gt;&lt;sys_overrides/&gt;&lt;sys_package display_value="Global" source="global"&gt;global&lt;/sys_package&gt;&lt;sys_policy/&gt;&lt;sys_scope display_value="Global"&gt;global&lt;/sys_scope&gt;&lt;sys_update_name&gt;sys_ui_action_3bf8aaad4f93230058224e318110c77f&lt;/sys_update_name&gt;&lt;sys_updated_by&gt;ab@dcm.fi&lt;/sys_updated_by&gt;&lt;sys_updated_on&gt;2021-10-29 07:44:19&lt;/sys_updated_on&gt;&lt;table&gt;x_jugr_dcm_available_relationships&lt;/table&gt;&lt;ui11_compatible&gt;true&lt;/ui11_compatible&gt;&lt;ui16_compatible&gt;false&lt;/ui16_compatible&gt;&lt;/sys_ui_action&gt;&lt;/record_update&gt;</payload>
<payload_hash>-960983178</payload_hash>
<remote_update_set display_value="DCM Addon Util - Cross scope privilege creator v2.3">212d43791b104110d90ae1db234bcb44</remote_update_set>
<replace_on_upgrade>false</replace_on_upgrade>
<sys_created_by>ab@dcm.fi</sys_created_by>
<sys_created_on>2021-12-09 07:24:26</sys_created_on>
<sys_id>2d2d43791b104110d90ae1db234bcb44</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_recorded_at>17ccb01b7d10000001</sys_recorded_at>
<sys_updated_by>ab@dcm.fi</sys_updated_by>
<sys_updated_on>2021-12-09 07:24:26</sys_updated_on>
<table>x_jugr_dcm_available_relationships</table>
<target_name>Set Up Scope Access for DCM</target_name>
<type>UI Action</type>
<update_domain>global</update_domain>
<update_guid>458880f855e33410f36fec18b7e4b62e</update_guid>
<update_guid_history>458880f855e33410f36fec18b7e4b62e:-960983178,0cd904ed3dba6010576920b62ad5aea3:-1898393248,ee9940ed60ba6010348c6e6955549b56:-1457067696,a036cc2dc8ba6010b75a56496c23223f:-378483101,c049aaad10932300bf5366e0edf168cc:56620871</update_guid_history>
<update_set display_value=""/>
<view/>
</sys_update_xml>
<sys_update_xml action="INSERT_OR_UPDATE">
<action>INSERT_OR_UPDATE</action>
<application display_value="Global">global</application>
<category>customer</category>
<comments/>
<name>sys_script_include_d7dc9974db0113001dee59d0cf961975</name>
<payload>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;record_update table="sys_script_include"&gt;&lt;sys_script_include action="INSERT_OR_UPDATE"&gt;&lt;access&gt;package_private&lt;/access&gt;&lt;active&gt;true&lt;/active&gt;&lt;api_name&gt;global.DCMAddOnCrossScopeUtil&lt;/api_name&gt;&lt;caller_access/&gt;&lt;client_callable&gt;false&lt;/client_callable&gt;&lt;description&gt;provides utility functions to create Application Cross-Scope Access records for DCM Available Class and Relationship records.&lt;/description&gt;&lt;name&gt;DCMAddOnCrossScopeUtil&lt;/name&gt;&lt;script&gt;&lt;![CDATA[var DCMAddOnCrossScopeUtil = Class.create();
DCMAddOnCrossScopeUtil.prototype = {
	// Setting up counters for record modifications
	iInsertCounter: 0,
	iExistingCounter: 0,
	DCM_SCOPE: {
		scope: 'x_jugr_dcm',
		sys_id: 'a87427360f592200d05a8fcce1050e22'
	},
	SELECTED_TABLES_DEF:{
		'x_jugr_dcm_available_classes':'x_jugr_dcm_m2m_tables_available_classes',
		'x_jugr_dcm_available_relationships':'x_jugr_dcm_m2m_tables_available_relationships'
	},
	initialize: function() {},


	/** 
	 * 
	 * @param  {GlideRecord} availableItemGR available config item (relationship or class)
	 * @param  {string}      comma seperated list of operations
	 * @return {string}         report on cross scope acess records 
	 */
	updatePrivileges: function(availableItemGR, operations) {
		this.availableEntityName = availableItemGR.getRecordClassName();
		var arrTableList = this.getClassTableList(availableItemGR);
		// Process all the tables in the array list
		for (var i in arrTableList) {
			// Create priviles for table 
			this.createPrivileges(arrTableList[i], operations);
		}
		return "Application Cross-Scope Access records modified:" +
			" Created " + this.iInsertCounter + " new records." +
			" Found " + this.iExistingCounter + " existing records.";

	},


	/**
	 * Creates Privilege records (read, write, create) for the given table
	 * @param  {sting}		strTableName	Name of the table
	 * @param  {string}     comma seperated operation list
	 */
	createPrivileges: function(strTableName, operations) {
		// List of operations DCM needs to have for the tables
		var arrOperations = operations? operations.split(",") : ["read", "write", "create"];
		var tblDef = this._getTable(strTableName);
		if(!tblDef) return;
		for (var o in arrOperations) {
			if (this.createPrivilege(tblDef, arrOperations[o])) {
				this.iInsertCounter++;
			} else {
				this.iExistingCounter++;
			}
		}
	},


	/**
	 * Creates a privilige record for DCM application for given table
	 * @param  {object}	tbl	table defination object
	 * @param  {string}  tbl.name  name of table
	 * @param  {string}  tbl.label  label of table
	 * @param  {string}  tbl.scope  scope id of table
	 * @param  {string}	strOperation	Operation to be allowed
	 * @return {boolean}				TRUE if record was created
	 */
	createPrivilege: function(tbl, strOperation) {
		var dcmScope = this.DCM_SCOPE.sys_id;

		var grScopePrivilege = new GlideRecord('sys_scope_privilege');
		grScopePrivilege.addQuery('source_scope', dcmScope);
		grScopePrivilege.addQuery('target_scope', tbl.scope);
		grScopePrivilege.addQuery('target_name', tbl.name);
		grScopePrivilege.addQuery('operation', strOperation);
		grScopePrivilege.query();
		
		if (!grScopePrivilege.next()) {
			// If record was not found, we will create new one
			grScopePrivilege.source_scope = dcmScope; 
			grScopePrivilege.status = "allowed";
			grScopePrivilege.target_scope = tbl.scope;
			grScopePrivilege.target_name = tbl.name;
			grScopePrivilege.target_type = "sys_db_object";
			grScopePrivilege.operation = strOperation;
			grScopePrivilege.insert();

			return true;
		} else {
			// Record was availabe, we do not touch it anymore
			return false;
		}
	},

	_getTable:function(tableName){
		var def = {};
		var grTable = new GlideRecord('sys_db_object');
		if (!grTable.get('name', tableName)) {
			gs.warn("DCM Add-on Cross Scope creator &gt;&gt; Table with name: " + tableName + "not found");
			return;
		}

		def.name=grTable.getValue('name');
		def.label = grTable.getValue('label');
		def.scope = grTable.getValue('sys_scope');

		return def;
	},

	/**
	 * Gets the table list for given class.
	 *
	 * @param      {glide record}  	availableItemGR  	DCM Class as glide record
	 * @return     {array}						Array list of tables included in the class
	 */
	getClassTableList: function(availableItemGR) {
		var arrTableList;
		var selectionType = availableItemGR.getValue('selection_type');

		// available relationship uses lower cased
		// available classes uses cpatalized
		// Process the classe with condition
		if (selectionType === "Condition" || selectionType === "condition")
			arrTableList = this.getTablesByCondition(availableItemGR.conditions.toString());

		// Process the class with Selected table list
		if (selectionType === "Tables" || selectionType === "tables")
			arrTableList = this.getSelectedTables(availableItemGR.sys_id.toString());

		// Add child tables to the list if the Inherit tables is enabled
		if (availableItemGR.inherit_tables)
			arrTableList = this.getChildTables(arrTableList);

		return arrTableList;
	},


	/**
	 * Gets the tables by condition string (encoded queery) in the class.
	 *
	 * @param      {string}  strCondition   Condition as encoded query
	 * @return     {Array}   				Array list of the tables matching to the condition.
	 */
	getTablesByCondition: function(strCondition) {

		var arrTableNames = [];
		var grTables = new GlideRecord('sys_db_object');
		grTables.addEncodedQuery(strCondition); // Query by given condition
		grTables.orderBy('name');
		grTables.query();
		while (grTables.next()) {
			arrTableNames.push(grTables.name.toString());
		}

		return arrTableNames;
	},


	/**
	 * Gets the tables from the selected tables related list.
	 *
	 * @param      {string}  strClassId		DCM class record's SYS ID
	 * @return     {Array}   				Array list of the selected table names
	 */
	getSelectedTables: function(strClassId) {
		var m2mTable = this.SELECTED_TABLES_DEF[this.availableEntityName];
		var listType = this.availableEntityName.replace('x_jugr_dcm_available_','');
		var arrTableNames = [];
		var grTableSelection = new GlideRecord(m2mTable);
		grTableSelection.addQuery('available_'+listType, strClassId); // Class is the parent
		grTableSelection.query();
		while (grTableSelection.next()) {
			arrTableNames.push(grTableSelection.table.name.toString());
		}

		return arrTableNames;
	},


	/**
	 * Gets the child tables for given table name array. Using recursion to get all the child tables from the structure.
	 *
	 * @param      {Array}  arrTableNames	Array of table names
	 * @return     {Array}  				Updated list of table names including child and grand child tables
	 */
	getChildTables: function(arrTableNames) {

		// If given array is empty, we just return empty array
		if (arrTableNames.length &lt; 1) return [];

		var arrChildTables = [];
		var grTables = new GlideRecord('sys_db_object');
		grTables.addQuery('super_class.name', "IN", arrTableNames.toString());
		grTables.orderBy('name');
		grTables.query();
		while (grTables.next()) {
			arrChildTables.push(grTables.name.toString());
		}

		// Get grandhildren by calling itself with child table name list
		var arrGrandChildTables = this.getChildTables(arrChildTables);

		var arrayUtil = new global.ArrayUtil();
		// Combine all arrays to one
		var arrAllTables = arrayUtil.union(arrTableNames, arrChildTables, arrGrandChildTables);
		// Return list with unique table names only
		return arrayUtil.unique(arrAllTables);
	},


	type: 'DCMAddOnCrossScopeUtil'
};]]&gt;&lt;/script&gt;&lt;sys_class_name&gt;sys_script_include&lt;/sys_class_name&gt;&lt;sys_created_by&gt;vl@justin.fi&lt;/sys_created_by&gt;&lt;sys_created_on&gt;2018-03-22 06:10:19&lt;/sys_created_on&gt;&lt;sys_id&gt;d7dc9974db0113001dee59d0cf961975&lt;/sys_id&gt;&lt;sys_mod_count&gt;28&lt;/sys_mod_count&gt;&lt;sys_name&gt;DCMAddOnCrossScopeUtil&lt;/sys_name&gt;&lt;sys_package display_value="Global" source="global"&gt;global&lt;/sys_package&gt;&lt;sys_policy/&gt;&lt;sys_scope display_value="Global"&gt;global&lt;/sys_scope&gt;&lt;sys_update_name&gt;sys_script_include_d7dc9974db0113001dee59d0cf961975&lt;/sys_update_name&gt;&lt;sys_updated_by&gt;ab@dcm.fi&lt;/sys_updated_by&gt;&lt;sys_updated_on&gt;2021-10-29 07:45:54&lt;/sys_updated_on&gt;&lt;/sys_script_include&gt;&lt;/record_update&gt;</payload>
<payload_hash>1039878262</payload_hash>
<remote_update_set display_value="DCM Addon Util - Cross scope privilege creator v2.3">212d43791b104110d90ae1db234bcb44</remote_update_set>
<replace_on_upgrade>false</replace_on_upgrade>
<sys_created_by>ab@dcm.fi</sys_created_by>
<sys_created_on>2021-12-09 07:24:26</sys_created_on>
<sys_id>652d43791b104110d90ae1db234bcb44</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_recorded_at>17ccb03283d0000001</sys_recorded_at>
<sys_updated_by>ab@dcm.fi</sys_updated_by>
<sys_updated_on>2021-12-09 07:24:26</sys_updated_on>
<table/>
<target_name>DCMAddOnCrossScopeUtil</target_name>
<type>Script Include</type>
<update_domain>global</update_domain>
<update_guid>c0e8cc3cf3e33410b0e3517441b41843</update_guid>
<update_guid_history>c0e8cc3cf3e33410b0e3517441b41843:1039878262,6e064c2d30ba60100f7d8b425271d501:904261440,eddc6a219bd32300418a12029e8cb09f:895155802,cb0c6a210cd32300934d9993c62e079a:612247370,1e5a2e61e5132300811ff47c0b5ebb75:-824289778,4b23a661e4132300045210e6772e5632:-1543586318,ced275611a132300b2be408b6c867c82:1232611543,b2afa561421323007ccee4cfe3106d2d:-1319943893,de0f696ded132300437bd5d244fee9f3:-978369863,5294e561bc132300d2f81f3067645f4c:-1707277570,f0c8767c1d811300f461ad8de402c86f:-253027764,27db2a3c8181130033f52bb28931be8a:-2026233395,735e69bc91011300f365ece6dc304302:1480155563,778c297cb7011300355b9c4989287ce3:1806098440,883761b86601130008b28d32d3903c85:-1307327931,a18661b8fc011300918d69c028610c31:-1942467746,71e5e178e901130094fea7fa03de80e1:-1542349880,64c525b8ff01130025b53a8164d17e46:1344223750,fb55a97854011300b7affbdf925fe95e:-768053232,a00561b8270113008d29ae05c4ada900:1600433210,6b24e978ef011300d3d864ad8f98387b:1394918371,3e042d785e011300db9d51065547c91a:-1423695361,9ea329785901130047c152cce8991052:-1041839664,6223a1785701130017f01ff9c2b16fb4:-1212580835,717221385d011300e2995f0c5be44d02:-559909913,5491adf4ea01130060caf185c3cf324d:1329950214,089f19b4fe0113005e08f5cd0fc06c72:-2072066397,eb8e11341a01130044ec5a0340f35bb2:1667241534,432d9534dc01130094cd8f7649ff9149:1772323220</update_guid_history>
<update_set display_value=""/>
<view/>
</sys_update_xml>
<sys_update_xml action="INSERT_OR_UPDATE">
<action>INSERT_OR_UPDATE</action>
<application display_value="Global">global</application>
<category>customer</category>
<comments/>
<name>sys_ui_page_faa972581b2ff81007eccbb5604bcb8e</name>
<payload>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;record_update table="sys_ui_page"&gt;&lt;sys_ui_page action="INSERT_OR_UPDATE"&gt;&lt;category&gt;general&lt;/category&gt;&lt;client_script&gt;&lt;![CDATA[(function(jQuery){
	
	function showMessage(msg, type){
		var messageDisplay = jQuery("#messageHolder");
		messageDisplay.text(msg).addClass("alert-" + type).removeClass("hidden");
	}
	
	function clearMessageDisplay(){
		var messageDisplay = jQuery("#messageHolder");
		messageDisplay.text("").addClass("hidden");
	}
	
	function validateInputs(){
		var availableConfigIds = jQuery("#sysIdList").val().trim();
		var configTable = jQuery("#tableName").val().trim();
		
		if(!availableConfigIds || !configTable){
			showMessage("Available record (relationship or class) config not selected", "danger");
			return false;
		}
		
		var selectedOperations = getSelectedOperations();
		if(!selectedOperations || !selectedOperations.length){
			showMessage("Select at least one operation", "danger");
			return false;
		}
		
		return true;
	}
	
	function _setSelectedOperation(){
		var operations = getSelectedOperations();
		jQuery("#selectedOperation").val(operations.join(","));
	}
	
	function selectDefaultOperation(operations){
		operations.forEach(function(operation){
			jQuery("#operationSelect input[value='"+ operation +"']").prop("checked", true);
		});
	}
	
	function clearOperationSelection(){
		jQuery("#operationSelect input.checkbox:checked").prop("checked", false);
	}
	
	function getSelectedOperations(){
		var selectedOperations = jQuery("#operationSelect input.checkbox:checked");
		if(selectedOperations.length){
			return selectedOperations.map(function(){ return this.value; }).get();
		}else{
			return [];
		}
	}
	
	function closeDialog(){
		GlideDialogWindow.get().destroy();
	}
	
	function submitForm(){
		var form = jQuery('form[name="dcmCrossScopeCreateForm"]');
		form.addClass("form-submitted");
		clearMessageDisplay();
		
		if(!validateInputs())
			return false;
		
		_setSelectedOperation();
		
		return true;
	}
	
	function init(){
		var defaultOperations = "$[JS:jvar_preferred_operations]";
		if(defaultOperations){
			defaultOperations = defaultOperations.split(",");
		}
		
		if(defaultOperations.length){
			clearOperationSelection();
			selectDefaultOperation(defaultOperations);
		}
	}
	
	var submitBtn = jQuery('#submitBtn');
	var cancelBtn = jQuery('#cancelBtn');
	submitBtn.on('click',submitForm);
	cancelBtn.on('click',closeDialog);
	
	init();
})(jQuery);]]&gt;&lt;/client_script&gt;&lt;description&gt;Modal/Dialog box to confirm cross-scope privileges creation for DCM application using selected available table configs&lt;/description&gt;&lt;direct&gt;false&lt;/direct&gt;&lt;endpoint/&gt;&lt;html&gt;&lt;![CDATA[&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"&gt;
	&lt;g:evaluate var="jvar_available_entity_GR" copyToPhase2="true"&gt;
		var sysIdList = RP.getWindowProperties().get("sys_id_list") || '';
		var tableName = RP.getWindowProperties().get("table_name");
		var availableEntityGR = null; 
		if(tableName ${AND} sysIdList){
			availableEntityGR = new GlideRecord(tableName);
			availableEntityGR.addQuery('sys_id','IN',sysIdList);
			availableEntityGR.query();
		}
		availableEntityGR;
	&lt;/g:evaluate&gt;
	&lt;style&gt;
		#operationSelect {
			min-width: auto;
			padding: 0.35em 0.625em;
		}
		#operationSelect legend{
			font-size: 17px;
			margin-bottom: 13px;
		}
		.config-item{
			margin-right:8px;
		}
	&lt;/style&gt;
	&lt;g:ui_form class="form-horizontal" name="dcmCrossScopeCreateForm"&gt;
		&lt;input type="hidden" id="sysIdList" name="sys_id_list" value="$[HTML:sysIdList]" /&gt;
		&lt;input type="hidden" id="tableName" name="table_name" value="$[HTML:tableName]" /&gt;
		&lt;input type="hidden" id="selectedOperation" name="selected_operation"/&gt; 
		&lt;div id="cspCreateConfirm"&gt;
			
			&lt;div class="col-sm-12"&gt;
				&lt;div class="alert alert-info"&gt;
					&lt;p&gt;cross-scope privilege records will be created from the following&lt;/p&gt;
				&lt;/div&gt;
				&lt;div id="availableTableConfigs" style="padding:0 15px 15px 15px;"&gt;
					&lt;j2:while test="$[availableEntityGR.next()]"&gt;
						&lt;a href="$[HTML:availableEntityGR.getLink()]" target="_blank" 
						   class="config-item"&gt;$[HTML:availableEntityGR.getDisplayValue()]&lt;/a&gt;
					&lt;/j2:while&gt;					
					
					&lt;j2:if test="$[empty(jvar_available_entity_GR)]"&gt;
						&lt;div class="alert alert-info"&gt;
							&lt;p&gt;Available record configs (relationship or class) not selected&lt;/p&gt;
						&lt;/div&gt;						
					&lt;/j2:if&gt;
				&lt;/div&gt;
			&lt;/div&gt;
			
			&lt;g2:evaluate var="jvar_preferred_operations"&gt;
				var currentUser = gs.getUser();
				var preferredOperations = currentUser.getPreference("dcm.csp.ceator.operations");
				if(!preferredOperations){
					preferredOperations = "";
				}
				preferredOperations;
			&lt;/g2:evaluate&gt;
			
			&lt;fieldset id="operationSelect"&gt;
				&lt;legend &gt;Selected operations&lt;/legend&gt;
				&lt;div class="form-group"&gt;
					&lt;div class="alert hidden" id="messageHolder"&gt;
						
					&lt;/div&gt;
				&lt;/div&gt;
				&lt;div class="form-group"&gt;
					&lt;div class="col-sm-12"&gt;
						&lt;span class="input-group-checkbox"&gt;
							&lt;input id="createOperation" class="checkbox" type="checkbox" name="operation" 
								   value="create" checked="true"/&gt;
							&lt;label for="createOperation" class="checkbox-label"&gt;Create&lt;/label&gt;
						&lt;/span&gt;
					&lt;/div&gt;
				&lt;/div&gt;
				&lt;div class="form-group"&gt;
					 &lt;div class="col-sm-12"&gt;
						&lt;span class="input-group-checkbox"&gt;
							&lt;input id="readOperation" class="checkbox" type="checkbox" name="operation" 
								   value="read" checked="true"/&gt;
							&lt;label for="readOperation" class="checkbox-label"&gt;Read&lt;/label&gt;
						&lt;/span&gt;
					 &lt;/div&gt;
				 &lt;/div&gt;
				 &lt;div class="form-group"&gt;
					 &lt;div class="col-sm-12"&gt;
						 &lt;span class="input-group-checkbox"&gt;
							 &lt;input id="writeOperation" class="checkbox" type="checkbox" name="operation" 
									value="write" checked="true"/&gt;
							 &lt;label for="writeOperation" class="checkbox-label"&gt;Write&lt;/label&gt;
						 &lt;/span&gt;
					 &lt;/div&gt;
				 &lt;/div&gt;
			&lt;/fieldset&gt;
			
			&lt;div class="modal-footer"&gt;
				&lt;button id="cancelBtn" class="btn btn-default" type="button"&gt;Cancel&lt;/button&gt;
				&lt;button id="submitBtn" class="btn btn-primary" type="submit"&gt;Create&lt;/button&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/g:ui_form&gt;	
&lt;/j:jelly&gt;]]&gt;&lt;/html&gt;&lt;name&gt;dcm_csp_create_dialog&lt;/name&gt;&lt;processing_script&gt;&lt;![CDATA[if(table_name &amp;&amp; sys_id_list &amp;&amp; selected_operation){
	setupCrossScopeAccess(table_name, sys_id_list, selected_operation);
	setOperationPreference(selected_operation);
}else{
	gs.addErrorMessage("Required parameters missing");
}
refresh();

/** 
*  setup cross scope access for available configuration provided
*  @param  {string}  configEntityTable  table_name of available config (relationship or class)
*  @param  {string}  configSysIds  comma seperated sys_id of available config records
*  @param  {string}  operations  comma seperated operation list
*/
function setupCrossScopeAccess(configEntityTable, configSysIds, operations){
	var messages = [];
	var cspCreator = new DCMAddOnCrossScopeUtil();
	var availableEntityGR = new GlideRecord(configEntityTable);
	availableEntityGR.addQuery('sys_id','IN',configSysIds);
	availableEntityGR.query();
	
	while(availableEntityGR.next()){
		var msg = cspCreator.updatePrivileges(availableEntityGR, operations);
		messages.push(msg);
	}
	
	gs.addInfoMessage(messages.join("&lt;br/&gt;"));
}

function setOperationPreference(operations){
	var currentUser = gs.getUser();
	currentUser.savePreference("dcm.csp.ceator.operations", operations);	
}

function refresh(){
	var urlOnStack = GlideSession.get().getStack().bottom();
	response.sendRedirect(urlOnStack);	
}
]]&gt;&lt;/processing_script&gt;&lt;sys_class_name&gt;sys_ui_page&lt;/sys_class_name&gt;&lt;sys_created_by&gt;ab@dcm.fi&lt;/sys_created_by&gt;&lt;sys_created_on&gt;2021-10-28 08:38:44&lt;/sys_created_on&gt;&lt;sys_id&gt;faa972581b2ff81007eccbb5604bcb8e&lt;/sys_id&gt;&lt;sys_mod_count&gt;63&lt;/sys_mod_count&gt;&lt;sys_name&gt;dcm_csp_create_dialog&lt;/sys_name&gt;&lt;sys_package display_value=""&gt;225eea501b2ff81007eccbb5604bcb80&lt;/sys_package&gt;&lt;sys_policy/&gt;&lt;sys_scope display_value="Global"&gt;global&lt;/sys_scope&gt;&lt;sys_update_name&gt;sys_ui_page_faa972581b2ff81007eccbb5604bcb8e&lt;/sys_update_name&gt;&lt;sys_updated_by&gt;ab@dcm.fi&lt;/sys_updated_by&gt;&lt;sys_updated_on&gt;2021-12-09 07:15:22&lt;/sys_updated_on&gt;&lt;/sys_ui_page&gt;&lt;/record_update&gt;</payload>
<payload_hash>-786451520</payload_hash>
<remote_update_set display_value="DCM Addon Util - Cross scope privilege creator v2.3">212d43791b104110d90ae1db234bcb44</remote_update_set>
<replace_on_upgrade>false</replace_on_upgrade>
<sys_created_by>ab@dcm.fi</sys_created_by>
<sys_created_on>2021-12-09 07:24:26</sys_created_on>
<sys_id>a12d43791b104110d90ae1db234bcb45</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_recorded_at>17d9e0bf2280000001</sys_recorded_at>
<sys_updated_by>ab@dcm.fi</sys_updated_by>
<sys_updated_on>2021-12-09 07:24:26</sys_updated_on>
<table/>
<target_name>dcm_csp_create_dialog</target_name>
<type>UI Page</type>
<update_domain>global</update_domain>
<update_guid>f01b4ff5fa104110f7a435eb584ffe23</update_guid>
<update_guid_history>f01b4ff5fa104110f7a435eb584ffe23:-786451520,d7da03b5541041108f699ae94cd2612a:-499214894,603ac7f5661041106774f85b01062e4c:-674182875,044883b5ba10411019a4c4ea8234e4c1:1027933263,aad2c7b1d310411027ce54ee0fada9dc:-161073997,2322cf719e104110e4a6111efde03e1e:-2021443876,ece2a87132980110693d4646d4da27fb:-68151070,0472a8710f980110991165b69f6a60f7:438908352,e6c64cfd8818011062bc2c1aea6e9d08:-443625985,fea64cf92b180110ebaf91f416a887ad:45325922,e2550cfdbc18011033ca97a3afc5f7da:2134118403,34ec97e5a3d40110806a71dc3f5909f4:-316383914,4ef9136589d401105368dfbf33a18a9b:-591380001,fbb89f2515d4011009001dfe4a172488:-2091557233,8c6757a13ed40110765064cf482fe992:-605995492,84748078dce33410d81bd2bb4135bd81:-321842155</update_guid_history>
<update_set display_value=""/>
<view/>
</sys_update_xml>
<sys_update_xml action="INSERT_OR_UPDATE">
<action>INSERT_OR_UPDATE</action>
<application display_value="Global">global</application>
<category>customer</category>
<comments/>
<name>sys_ui_action_7ebce97cdb0113001dee59d0cf961930</name>
<payload>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;record_update sys_domain="global" table="sys_ui_action"&gt;&lt;sys_ui_action action="INSERT_OR_UPDATE"&gt;&lt;action_name/&gt;&lt;active&gt;true&lt;/active&gt;&lt;client&gt;true&lt;/client&gt;&lt;client_script_v2&gt;&lt;![CDATA[function onClick(g_form) {

}]]&gt;&lt;/client_script_v2&gt;&lt;comments&gt;creats cross scope privilege entries&lt;/comments&gt;&lt;condition&gt;gs.getProperty('x_jugr_dcm.app_exist')==='true'?gs.hasRole("admin"):false&lt;/condition&gt;&lt;form_action&gt;true&lt;/form_action&gt;&lt;form_button&gt;true&lt;/form_button&gt;&lt;form_button_v2&gt;false&lt;/form_button_v2&gt;&lt;form_context_menu&gt;false&lt;/form_context_menu&gt;&lt;form_link&gt;false&lt;/form_link&gt;&lt;form_menu_button_v2&gt;false&lt;/form_menu_button_v2&gt;&lt;form_style/&gt;&lt;hint/&gt;&lt;isolate_script&gt;false&lt;/isolate_script&gt;&lt;list_action&gt;true&lt;/list_action&gt;&lt;list_banner_button&gt;false&lt;/list_banner_button&gt;&lt;list_button&gt;false&lt;/list_button&gt;&lt;list_choice&gt;true&lt;/list_choice&gt;&lt;list_context_menu&gt;false&lt;/list_context_menu&gt;&lt;list_link&gt;false&lt;/list_link&gt;&lt;list_save_with_form_button&gt;false&lt;/list_save_with_form_button&gt;&lt;list_style/&gt;&lt;messages/&gt;&lt;name&gt;Set Up Scope Access for DCM&lt;/name&gt;&lt;onclick&gt;openCrossScopeCreateModal()&lt;/onclick&gt;&lt;order&gt;100&lt;/order&gt;&lt;script&gt;&lt;![CDATA[function openCrossScopeCreateModal(){
	var dialog = new GlideModal("dcm_csp_create_dialog");
    dialog.setTitle("Confirm Cross-Scope Access");
	dialog.setPreference("sys_id_list", getSysIdList());
	dialog.setPreference("table_name", getTableName());
	dialog.render();	
}

function getTableName(){
	if(window.g_list){
		return g_list.getTableName();
	}else if(window.g_form){
		return g_form.getTableName();
	}
}

function getSysIdList(){
	if(window.g_list &amp;&amp; (typeof g_sysId == "undefined" || !g_sysId)){
		
		return  g_list.getChecked();
	}else if(window.g_sys_id &amp;&amp; !window.g_form){
		// only row id on which context menu opened
		// rowSysId is legacy
		return g_sysId;
	}else if(window.g_form){
		return g_form.getUniqueValue();
	}		
}]]&gt;&lt;/script&gt;&lt;show_insert&gt;false&lt;/show_insert&gt;&lt;show_multiple_update&gt;false&lt;/show_multiple_update&gt;&lt;show_query&gt;false&lt;/show_query&gt;&lt;show_update&gt;true&lt;/show_update&gt;&lt;sys_class_name&gt;sys_ui_action&lt;/sys_class_name&gt;&lt;sys_created_by&gt;vl@justin.fi&lt;/sys_created_by&gt;&lt;sys_created_on&gt;2018-03-22 07:19:38&lt;/sys_created_on&gt;&lt;sys_domain&gt;global&lt;/sys_domain&gt;&lt;sys_domain_path&gt;/&lt;/sys_domain_path&gt;&lt;sys_id&gt;7ebce97cdb0113001dee59d0cf961930&lt;/sys_id&gt;&lt;sys_mod_count&gt;9&lt;/sys_mod_count&gt;&lt;sys_name&gt;Set Up Scope Access for DCM&lt;/sys_name&gt;&lt;sys_overrides/&gt;&lt;sys_package display_value="Global" source="global"&gt;global&lt;/sys_package&gt;&lt;sys_policy/&gt;&lt;sys_scope display_value="Global"&gt;global&lt;/sys_scope&gt;&lt;sys_update_name&gt;sys_ui_action_7ebce97cdb0113001dee59d0cf961930&lt;/sys_update_name&gt;&lt;sys_updated_by&gt;ab@dcm.fi&lt;/sys_updated_by&gt;&lt;sys_updated_on&gt;2021-10-29 07:42:59&lt;/sys_updated_on&gt;&lt;table&gt;x_jugr_dcm_available_classes&lt;/table&gt;&lt;ui11_compatible&gt;true&lt;/ui11_compatible&gt;&lt;ui16_compatible&gt;false&lt;/ui16_compatible&gt;&lt;/sys_ui_action&gt;&lt;/record_update&gt;</payload>
<payload_hash>1450322539</payload_hash>
<remote_update_set display_value="DCM Addon Util - Cross scope privilege creator v2.3">212d43791b104110d90ae1db234bcb44</remote_update_set>
<replace_on_upgrade>false</replace_on_upgrade>
<sys_created_by>ab@dcm.fi</sys_created_by>
<sys_created_on>2021-12-09 07:24:26</sys_created_on>
<sys_id>ed2d43791b104110d90ae1db234bcb44</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_recorded_at>17ccb007d780000001</sys_recorded_at>
<sys_updated_by>ab@dcm.fi</sys_updated_by>
<sys_updated_on>2021-12-09 07:24:26</sys_updated_on>
<table>x_jugr_dcm_available_classes</table>
<target_name>Set Up Scope Access for DCM</target_name>
<type>UI Action</type>
<update_domain>global</update_domain>
<update_guid>9138c4f83de334100efd9bad2d568f47</update_guid>
<update_guid_history>9138c4f83de334100efd9bad2d568f47:1450322539,e6d904edb6ba601093dffe6c0a78cf77:89755929,75a980ed62ba6010d5a6c7af64387e06:-1883749591,df56006da3ba6010d9d4d3c90f413477:695198204,47036ea92e9323009e961fd7a0be74dc:1099830994,1e60b5ad361323006d666fd2302e881b:-1661883474,615d667c9a811300ebde869585363c37:8124664,090d6e3c8a811300a972f14e5abc20a6:1717291351,99dc6a3c20811300d17d4f29c8735678:1340479275,ea0da5b800011300b276b4e7968b7ce8:-2136017733</update_guid_history>
<update_set display_value=""/>
<view/>
</sys_update_xml>
</unload>
