Last active
May 1, 2018 00:20
-
-
Save jmbauguess/cbd1d6edc023da2d69df to your computer and use it in GitHub Desktop.
Contains functionality for copying data from a child to its parent once the parent commits the update set. Useful for moving metadata that normally does not move in update sets. See http://sensibleservicenow.com/?p=49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<unload unload_date="2015-08-14 22:59:24"> | |
<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>Copies data from one instance to another once it's committed. Useful for when you need to import meta data.</description> | |
<inserted/> | |
<name>SNDataCopy</name> | |
<origin_sys_id/> | |
<release_date/> | |
<remote_sys_id>ff63fa364fb94200380f3879b110c7f7</remote_sys_id> | |
<state>loaded</state> | |
<summary/> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>2c34efba4fb94200380f3879b110c7be</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</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_rest_message_b41436b64fb94200380f3879b110c768</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_rest_message"><sys_rest_message action="INSERT_OR_UPDATE"><access>package_private</access><basic_auth_password/><basic_auth_user/><description>Runs after Automated Commitments to retrieve data from a lower environment based on information from the update set itself.</description><name>Automated Data Retrieval</name><protocol_name/><rest_endpoint>https://${environment}.service-now.com/${table_name}.do?JSON</rest_endpoint><sys_class_name>sys_rest_message</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:29:33</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>b41436b64fb94200380f3879b110c768</sys_id><sys_mod_count>0</sys_mod_count><sys_name>Automated Data Retrieval</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_rest_message_b41436b64fb94200380f3879b110c768</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:29:33</sys_updated_on><use_basic_auth>false</use_basic_auth><use_mutual_auth>false</use_mutual_auth></sys_rest_message></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>2034efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>Automated Data Retrieval</target_name> | |
<type>REST Message</type> | |
<update_domain>global</update_domain> | |
<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_rest_message_fn_e62436b64fb94200380f3879b110c70d</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_rest_message_fn"><sys_rest_message_fn action="INSERT_OR_UPDATE"><basic_auth_password/><basic_auth_user/><content/><function_name>delete</function_name><lock>false</lock><protocol_name/><rest_endpoint>https://${environment}.service-now.com/${table_name}.do?JSON</rest_endpoint><rest_message display_value="Automated Data Retrieval">b41436b64fb94200380f3879b110c768</rest_message><sys_class_name>sys_rest_message_fn</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:29:33</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>e62436b64fb94200380f3879b110c70d</sys_id><sys_mod_count>0</sys_mod_count><sys_name>delete</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_rest_message_fn_e62436b64fb94200380f3879b110c70d</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:29:33</sys_updated_on><use_basic_auth>false</use_basic_auth><use_mid_server/><use_mutual_auth>false</use_mutual_auth></sys_rest_message_fn></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>2434efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>delete</target_name> | |
<type>HTTP Method</type> | |
<update_domain>global</update_domain> | |
<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_section_5004c388c0a8016c0092cd1419fabca3</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update><sys_ui_section caption="" section_id="5004c388c0a8016c0092cd1419fabca3" sys_domain="global" table="sys_update_set" version="3" view=""><sys_ui_element action="INSERT_OR_UPDATE"><element>.begin_split</element><position>0</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>2dfcc433c3032100a77f4ddcddba8f98</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type>.begin_split</type></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>name</element><position>1</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>6dfcc433c3032100a77f4ddcddba8f98</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>state</element><position>2</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>adfcc433c3032100a77f4ddcddba8f98</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>release_date</element><position>3</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>edfcc433c3032100a77f4ddcddba8f98</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>install_date</element><position>4</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>21fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>installed_from</element><position>5</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>61fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>.split</element><position>6</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>a1fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type>.split</type></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>application</element><position>7</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>e1fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>sys_created_on</element><position>8</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>25fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>sys_created_by</element><position>9</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>65fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>merged_to</element><position>10</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>a5fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>.end_split</element><position>11</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>e5fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type>.end_split</type></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>description</element><position>12</position><sys_created_by>michael.hoefer</sys_created_by><sys_created_on>2014-09-15 20:49:08</sys_created_on><sys_id>29fcc433c3032100a77f4ddcddba8f99</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>michael.hoefer</sys_updated_by><sys_updated_on>2014-09-15 20:49:08</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>u_release_name</element><position>13</position><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-12 17:27:20</sys_created_on><sys_id>7405cc964fb54200380f3879b110c7a2</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-12 17:27:20</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>u_migration_plan</element><position>14</position><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-12 17:27:58</sys_created_on><sys_id>822544d64fb54200380f3879b110c77c</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-12 17:27:58</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_element action="INSERT_OR_UPDATE"><element>u_import_data</element><position>15</position><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:32:14</sys_created_on><sys_id>4ac4f2364fb94200380f3879b110c7c5</sys_id><sys_mod_count>0</sys_mod_count><sys_ui_formatter/><sys_ui_section caption="NULL" display_value="" name="sys_update_set" sys_domain="global" view="Default view">5004c388c0a8016c0092cd1419fabca3</sys_ui_section><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:32:14</sys_updated_on><sys_user/><type/></sys_ui_element><sys_ui_section action="INSERT_OR_UPDATE"><caption/><header>false</header><name>sys_update_set</name><roles/><sys_class_name>sys_ui_section</sys_class_name><sys_created_by>glide.maint</sys_created_by><sys_created_on>2007-01-23 17:33:13</sys_created_on><sys_customer_update>false</sys_customer_update><sys_domain>global</sys_domain><sys_domain_path>/</sys_domain_path><sys_id>5004c388c0a8016c0092cd1419fabca3</sys_id><sys_mod_count>3</sys_mod_count><sys_name>sys_update_set</sys_name><sys_overrides/><sys_package display_value="System Update Sets (with remote update set support)" source="com.glide.system_update_set">262f48154f133100380f3879b110c7b5</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_ui_section_5004c388c0a8016c0092cd1419fabca3</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:32:15</sys_updated_on><sys_user/><title>true</title><view display_value="Default view" name="NULL">Default view</view><view_name/></sys_ui_section></sys_ui_section></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>2834efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table>sys_update_set</table> | |
<target_name>Update Set</target_name> | |
<type>Form Layout</type> | |
<update_domain>global</update_domain> | |
<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_rest_message_fn_2a2436b64fb94200380f3879b110c70c</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_rest_message_fn"><sys_rest_message_fn action="INSERT_OR_UPDATE"><basic_auth_password/><basic_auth_user/><content/><function_name>get</function_name><lock>false</lock><protocol_name/><rest_endpoint>https://${environment}.service-now.com/${table_name}.do?JSON&sysparm_action=getRecords</rest_endpoint><rest_message display_value="Automated Data Retrieval">b41436b64fb94200380f3879b110c768</rest_message><sys_class_name>sys_rest_message_fn</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:29:33</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>2a2436b64fb94200380f3879b110c70c</sys_id><sys_mod_count>1</sys_mod_count><sys_name>get</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_rest_message_fn_2a2436b64fb94200380f3879b110c70c</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:30:32</sys_updated_on><use_basic_auth>false</use_basic_auth><use_mid_server/><use_mutual_auth>false</use_mutual_auth></sys_rest_message_fn></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>6034efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>get</target_name> | |
<type>HTTP Method</type> | |
<update_domain>global</update_domain> | |
<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_e8257ab64fb94200380f3879b110c7a5</name> | |
<payload><?xml version="1.0" encoding="UTF-8"?><record_update sys_domain="global" table="sys_script"><sys_script action="INSERT_OR_UPDATE"><abort_action>false</abort_action><access>package_private</access><action_delete>false</action_delete><action_insert>false</action_insert><action_query>false</action_query><action_update>true</action_update><active>true</active><add_message>false</add_message><advanced>true</advanced><client_callable>false</client_callable><collection>sys_remote_update_set</collection><condition>current.state.changesTo("committed") &amp;&amp; !current.update_set.u_import_data.nil()</condition><description/><execute_function>true</execute_function><filter_condition/><message/><name>Automatically Run Import Data on Commit</name><order>100</order><priority>100</priority><role_conditions/><script><![CDATA[function onAfter(current, previous) { | |
var listOfTables = u_import_data.split(','), counter; | |
for (counter = 0; counter < listOfTables.length; counter++) { | |
new SNDataCopy(new JSONToGlide()).copyData(listOfTables[i]); | |
} | |
}]]></script><sys_class_name>sys_script</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:35:09</sys_created_on><sys_customer_update>true</sys_customer_update><sys_domain>global</sys_domain><sys_domain_path/><sys_id>e8257ab64fb94200380f3879b110c7a5</sys_id><sys_mod_count>0</sys_mod_count><sys_name>Automatically Run Import Data on Commit</sys_name><sys_overrides/><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_script_e8257ab64fb94200380f3879b110c7a5</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:35:09</sys_updated_on><template/><when>after</when></sys_script><sys_translated_text action="delete_multiple" query="documentkey=e8257ab64fb94200380f3879b110c7a5"/></record_update></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>6434efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table>sys_remote_update_set</table> | |
<target_name>Automatically Run Import Data on Commit</target_name> | |
<type>Business Rule</type> | |
<update_domain>global</update_domain> | |
<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_dictionary_sys_update_set_u_import_data</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update><sys_dictionary action="INSERT_OR_UPDATE" element="u_import_data" table="sys_update_set"><active>true</active><array>false</array><attributes/><audit>false</audit><calculation/><choice/><choice_field/><choice_table/><column_label>Import Data</column_label><comments/><create_roles/><default_value/><defaultsort/><delete_roles/><dependent/><dependent_on_field/><display>false</display><dynamic_creation>false</dynamic_creation><dynamic_creation_script/><dynamic_default_value/><dynamic_ref_qual/><element>u_import_data</element><element_reference>false</element_reference><foreign_database/><internal_type display_value="">glide_list</internal_type><mandatory>false</mandatory><max_length>4000</max_length><name>sys_update_set</name><next_element/><primary>false</primary><read_only>false</read_only><read_roles/><reference display_value="" name="sys_db_object">sys_db_object</reference><reference_cascade_rule/><reference_floats>false</reference_floats><reference_key/><reference_qual/><reference_qual_condition/><reference_type/><sizeclass/><spell_check>false</spell_check><sys_class_name>sys_dictionary</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:32:14</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>2994b6b64fb94200380f3879b110c7dd</sys_id><sys_mod_count>0</sys_mod_count><sys_name>Import Data</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_dictionary_sys_update_set_u_import_data</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:32:14</sys_updated_on><table_reference>false</table_reference><text_index>false</text_index><unique>false</unique><use_dependent_field>false</use_dependent_field><use_dynamic_default>false</use_dynamic_default><use_reference_qualifier>simple</use_reference_qualifier><virtual>false</virtual><widget/><write_roles/><xml_view>false</xml_view></sys_dictionary></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>6c34efba4fb94200380f3879b110c7be</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table>sys_update_set</table> | |
<target_name>Update Set.Import Data</target_name> | |
<type>Dictionary</type> | |
<update_domain>global</update_domain> | |
<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_rest_message_fn_6e2436b64fb94200380f3879b110c70c</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_rest_message_fn"><sys_rest_message_fn action="INSERT_OR_UPDATE"><basic_auth_password/><basic_auth_user/><content/><function_name>post</function_name><lock>false</lock><protocol_name/><rest_endpoint>https://${environment}.service-now.com/${table_name}.do?JSON</rest_endpoint><rest_message display_value="Automated Data Retrieval">b41436b64fb94200380f3879b110c768</rest_message><sys_class_name>sys_rest_message_fn</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:29:33</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>6e2436b64fb94200380f3879b110c70c</sys_id><sys_mod_count>0</sys_mod_count><sys_name>post</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_rest_message_fn_6e2436b64fb94200380f3879b110c70c</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:29:33</sys_updated_on><use_basic_auth>false</use_basic_auth><use_mid_server/><use_mutual_auth>false</use_mutual_auth></sys_rest_message_fn></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>a034efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>post</target_name> | |
<type>HTTP Method</type> | |
<update_domain>global</update_domain> | |
<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_3ae4f3eb4fcd0200380f3879b110c71e</name> | |
<payload><?xml version="1.0" encoding="UTF-8"?><record_update table="sys_script_include"><sys_script_include action="INSERT_OR_UPDATE"><access>package_private</access><active>true</active><api_name>global.JSONtoGlide</api_name><client_callable>false</client_callable><description>Converts between JSON Objects and GlideRecords</description><name>JSONtoGlide</name><script><![CDATA[/** | |
* @description Converts between JSON Objects and GlideRecords | |
* @namespace | |
* @type {Class} | |
*/ | |
var JSONtoGlide = Class.create(); | |
JSONtoGlide.prototype = { | |
/** | |
* @description Converts an object into a new GlideRecord | |
* @param {Object} json A json object | |
* @return {GlideRecord} A GlideRecord object | |
* @example | |
* var incident = { "_collection_type" : "incident", "short_description" : "Example"}; | |
* var incidentRecord = new JSONtoGlide().marshall(incident); | |
*/ | |
marshall: function(json) { | |
if (!this.validateCollectionExists(json._collection_type)) { | |
gs.log("INVALID COLLECTION : " + json._collection_type, "JSONtoGlide"); | |
return ''; | |
} | |
var glideRecord = new GlideRecord(json._collection_type), | |
item; | |
if (!json.hasOwnProperty('sys_id')) { | |
glideRecord.initialize(); | |
} else { | |
glideRecord.get(json.sys_id); | |
} | |
for (item in json) { | |
if (json.hasOwnProperty(item)) { | |
glideRecord.setValue(item, json[item]); | |
} | |
} | |
if (!json.hasOwnProperty('sys_id')) { | |
glideRecord.insert(); | |
} else { | |
glideRecord.update(); | |
} | |
return glideRecord; | |
}, | |
/** | |
* @description Converts a GlideRecord into an object | |
* @param {GlideRecord} record A GlideRecord | |
* @return {Object} A json object | |
* @example | |
* var incident = new GlideRecord('incident'), | |
* object; | |
* if (incident.get('sys_id')) { | |
* object = new JSONtoGlide().unmarshall(incident); | |
* } | |
*/ | |
unmarshall: function(record) { | |
var fields = new GlideRecordUtil().getFields(record), | |
resultObject = {}, | |
field; | |
for (field in fields) { | |
resultObject[fields[field]] = record.getValue(fields[field]); | |
} | |
return resultObject; | |
}, | |
/** | |
* @description Ensures a table exists before trying to create a GlideRecord | |
* @param {String} name The name of the table | |
* @return {boolean} True if the table exists, false otherwise | |
* @example | |
* new JSONtoGlide().validateCollectionExists('incident'); //true | |
* new JSONtoGlide().validateCollectionExists('fake_table'); //false | |
*/ | |
validateCollectionExists: function(name) { | |
var table = new GlideRecord('sys_db_object'); | |
if (table.get('name', name)) { | |
return true; | |
} | |
return false; | |
}, | |
type: 'JSONtoGlide' | |
};]]></script><sys_class_name>sys_script_include</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-07-11 01:21:10</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>3ae4f3eb4fcd0200380f3879b110c71e</sys_id><sys_mod_count>12</sys_mod_count><sys_name>JSONtoGlide</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_script_include_3ae4f3eb4fcd0200380f3879b110c71e</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:36:06</sys_updated_on></sys_script_include></record_update></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>a434efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>JSONtoGlide</target_name> | |
<type>Script Include</type> | |
<update_domain>global</update_domain> | |
<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_documentation_sys_update_set_u_import_data_en</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update><sys_documentation element="u_import_data" label="Import Data" language="en" table="sys_update_set"><sys_documentation action="INSERT_OR_UPDATE"><element>u_import_data</element><help/><hint/><label>Import Data</label><language>en</language><name>sys_update_set</name><plural>Import Data</plural><sys_class_name>sys_documentation</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:32:15</sys_created_on><sys_customer_update>false</sys_customer_update><sys_id>82c4f2364fb94200380f3879b110c7c6</sys_id><sys_mod_count>0</sys_mod_count><sys_name>Import Data</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_documentation_sys_update_set_u_import_data_en</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:32:15</sys_updated_on><url/><url_target/></sys_documentation></sys_documentation></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>ac34efba4fb94200380f3879b110c7be</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table>sys_update_set</table> | |
<target_name>Update Set.Import Data</target_name> | |
<type>Field Label</type> | |
<update_domain>global</update_domain> | |
<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_rest_message_fn_a22436b64fb94200380f3879b110c70d</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_rest_message_fn"><sys_rest_message_fn action="INSERT_OR_UPDATE"><basic_auth_password/><basic_auth_user/><content/><function_name>put</function_name><lock>false</lock><protocol_name/><rest_endpoint>https://${environment}.service-now.com/${table_name}.do?JSON</rest_endpoint><rest_message display_value="Automated Data Retrieval">b41436b64fb94200380f3879b110c768</rest_message><sys_class_name>sys_rest_message_fn</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:29:33</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>a22436b64fb94200380f3879b110c70d</sys_id><sys_mod_count>0</sys_mod_count><sys_name>put</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_rest_message_fn_a22436b64fb94200380f3879b110c70d</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:29:33</sys_updated_on><use_basic_auth>false</use_basic_auth><use_mid_server/><use_mutual_auth>false</use_mutual_auth></sys_rest_message_fn></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>e034efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>put</target_name> | |
<type>HTTP Method</type> | |
<update_domain>global</update_domain> | |
<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_b593f2b64fb94200380f3879b110c766</name> | |
<payload><?xml version="1.0" encoding="UTF-8"?><record_update table="sys_script_include"><sys_script_include action="INSERT_OR_UPDATE"><access>package_private</access><active>true</active><api_name>global.SNDataCopy</api_name><client_callable>false</client_callable><description>Copies data from one instance to another using web services</description><name>SNDataCopy</name><script><![CDATA[/** | |
* @description Copies data from one instance to another using web services | |
* @namespace | |
* @type {Class} | |
* @example | |
* //From Business Rule | |
* for (var i = 0; i < listOfTables.length; i++) { | |
* new SNDataCopy(new JSONToGlide()).copyData(listOfTables[i]); | |
* } | |
*/ | |
var SNDataCopy = Class.create(); | |
SNDataCopy.prototype = { | |
/** | |
* @description Inject the JSONToGlide (or other) json utility object | |
* @param {object} jsonUtil An object to handle JSON | |
*/ | |
initialize: function(jsonUtil) { | |
this.jsonUtil = jsonUtil; | |
}, | |
/** | |
* @description Main method. Give a table name, calls a web service to retrieve data and makes it into glide records | |
* @param {string} table The name ofa table | |
* @return {string} the sys_id of the created or updated record | |
*/ | |
copyData: function(table) { | |
var restMessage = new RESTMessage('Automated Data Retrieval', 'get'), objects, object; | |
restMessage.setStringParameter('environment', gs.getProperty('sync.child.environment')); | |
restMessage.setStringParameter('table_name', table); | |
objects = new JSON().decode(restMessage.execute().getBody()).records; | |
for (object in objects) { | |
if (this.checkExistingRecord(objects[object].sys_id, table)) { | |
return this.updateExistingRecord(objects[object], table); | |
} else { | |
return this.createNewRecord(objects[object], table); | |
} | |
} | |
}, | |
/** | |
* @description Checks if a record exists alread | |
* @param {string} sys_id The sys_id to check for | |
* @param {string} table The table to check for | |
* @return {boolean} true if the record exists; false if not | |
*/ | |
checkExistingRecord: function(sys_id, table) { | |
if (this.jsonUtil !== undefined) { | |
if (!this.jsonUtil.validateCollectionExists(table)) { | |
return false; | |
} | |
} | |
var gr = new GlideRecord(table); | |
if (gr.get(sys_id)) { | |
return true; | |
} | |
return false; | |
}, | |
/** | |
* @description Updates an existing record | |
* @param {string} object JSON representation of a record | |
* @param {string} table The table name | |
* @return {string} The sys_id of the updated record | |
*/ | |
updateExistingRecord: function(object, table) { | |
if (this.jsonUtil === undefined) { | |
var gr = new GlideRecord(table), o; | |
if (gr.get(object.sys_id)) { | |
for (o in object) { | |
if (object.hasOwnProperty(o)) { | |
gr.setValue(o, object[o]); | |
} | |
} | |
return gr.update(); | |
} | |
} else { | |
object._collection_type = table; | |
return this.jsonUtil.marshall(object).sys_id; | |
} | |
}, | |
/** | |
* @description Creates a new record | |
* @param {string} object JSON representation of a record | |
* @param {string} table The table name | |
* @return {string} The sys_id of the created record | |
*/ | |
createNewRecord: function(object, table) { | |
if (this.jsonUtil === undefined) { | |
var gr = new GlideRecord(table), o; | |
gr.initialize(); | |
for (o in object) { | |
if (object.hasOwnProperty(o)) { | |
gr.setValue(o, object[o]); | |
} | |
} | |
return gr.insert(); | |
} else { | |
object._collection_type = table; | |
return this.jsonUtil.marshall(object).sys_id; | |
} | |
}, | |
type: 'SNDataCopy' | |
};]]></script><sys_class_name>sys_script_include</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 19:28:56</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>b593f2b64fb94200380f3879b110c766</sys_id><sys_mod_count>0</sys_mod_count><sys_name>SNDataCopy</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_script_include_b593f2b64fb94200380f3879b110c766</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 19:28:56</sys_updated_on></sys_script_include></record_update></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>e434efba4fb94200380f3879b110c7bf</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>SNDataCopy</target_name> | |
<type>Script Include</type> | |
<update_domain>global</update_domain> | |
<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_properties_2fa36fba4fb94200380f3879b110c7cc</name> | |
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_properties"><sys_properties action="INSERT_OR_UPDATE"><choices/><description>The child environment, used for SNDataCopy</description><ignore_cache>false</ignore_cache><is_private>false</is_private><name>sync.child.environment</name><read_roles/><suffix/><sys_class_name>sys_properties</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>2015-08-14 22:57:49</sys_created_on><sys_customer_update>true</sys_customer_update><sys_id>2fa36fba4fb94200380f3879b110c7cc</sys_id><sys_mod_count>1</sys_mod_count><sys_name>sync.child.environment</sys_name><sys_package display_value="Global" source="global">global</sys_package><sys_policy/><sys_replace_on_upgrade>false</sys_replace_on_upgrade><sys_scope display_value="Global">global</sys_scope><sys_update_name>sys_properties_2fa36fba4fb94200380f3879b110c7cc</sys_update_name><sys_updated_by>admin</sys_updated_by><sys_updated_on>2015-08-14 22:58:59</sys_updated_on><type>string</type><value/><write_roles/></sys_properties><sys_translated_text action="delete_multiple" query="documentkey=2fa36fba4fb94200380f3879b110c7cc"/></record_update>]]></payload> | |
<remote_update_set display_value="SNDataCopy">2c34efba4fb94200380f3879b110c7be</remote_update_set> | |
<replace_on_upgrade>false</replace_on_upgrade> | |
<sys_created_by>admin</sys_created_by> | |
<sys_created_on>2015-08-14 22:59:24</sys_created_on> | |
<sys_id>ec34efba4fb94200380f3879b110c7be</sys_id> | |
<sys_mod_count>0</sys_mod_count> | |
<sys_updated_by>admin</sys_updated_by> | |
<sys_updated_on>2015-08-14 22:59:24</sys_updated_on> | |
<table/> | |
<target_name>sync.child.environment</target_name> | |
<type>System Property</type> | |
<update_domain>global</update_domain> | |
<update_set display_value=""/> | |
<view/> | |
</sys_update_xml> | |
</unload> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment