<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_script_include">
    <sys_script_include action="INSERT_OR_UPDATE">
        <access>public</access>
        <active>true</active>
        <api_name>x_turbo_turbonomic.TurbonomicFieldMapUtil</api_name>
        <caller_access/>
        <client_callable>false</client_callable>
        <description/>
        <name>TurbonomicFieldMapUtil</name>
        <script><![CDATA[/**
 * When creating this script file, make sure "Accessible from" is set to "All application scopes"
 * otherwise sometimes when the field map runs, you will see errors like:
 * WARNING *** WARNING *** Evaluator: java.lang.SecurityException: Illegal access to private script include TurbonomicActionUtils in scope x_turbo_turbonomic being called from scope global
 */
var TurbonomicFieldMapUtil =  (function () {

    TurbonomicFieldMapUtil.prototype.type = 'TurbonomicFieldMapUtil';

    function TurbonomicFieldMapUtil() {
    }

    /**
     * Return the sys_id of an existing record if it exists. When using this in a field map,
     * 'Use source script', 'Coalesce', and 'Coalesce empty fields' must be checked. Also,
     * 'Target field' must be set to Sys ID.
     *
     * @param source The source row in the import set that has source.u_update_sys_id indicating
     *               an update. source.u_update_sys_id is not provided when an insert is needed.
     *
     * @return the sys_id of an existing record if it exists, -1 if not found or source.u_update_sys_id
     * @deprecated Do not use this method anymore to get/set the Sys ID in transform map scripts.
     */
    TurbonomicFieldMapUtil.prototype.findExistingSysIdFromFieldMap = function(searchTable, source) {
        if(source.u_update_sys_id) {
            var existing = new GlideRecordSecure(searchTable);
            if(existing.get(source.u_update_sys_id)) {
                return existing.sys_id; // indicates update
            } else {
                return -1; // indicates insert
            }
        } else {
            return -1; // indicates insert
        }
    };

    return TurbonomicFieldMapUtil;

}());
]]></script>
        <sys_class_name>sys_script_include</sys_class_name>
        <sys_created_by>admin</sys_created_by>
        <sys_created_on>2019-08-09 20:47:30</sys_created_on>
        <sys_id>6cc0d9a7db033300373fe04a4896190a</sys_id>
        <sys_mod_count>3</sys_mod_count>
        <sys_name>TurbonomicFieldMapUtil</sys_name>
        <sys_package display_value="Turbonomic Actions" source="x_turbo_turbonomic">be4eeab2db007f005e691fe968961902</sys_package>
        <sys_policy>read</sys_policy>
        <sys_scope display_value="Turbonomic Actions">be4eeab2db007f005e691fe968961902</sys_scope>
        <sys_update_name>sys_script_include_6cc0d9a7db033300373fe04a4896190a</sys_update_name>
        <sys_updated_by>alexpetrean</sys_updated_by>
        <sys_updated_on>2023-11-02 20:21:44</sys_updated_on>
    </sys_script_include>
</record_update>
