LogoLogo
AboutSupport
4.3
4.3
  • Unifi User Documentation
  • Install
    • Release Notes
      • Unifi 4.3 Release Notes
      • Unifi 4.2 Release Notes
      • Unifi 4.1 Release Notes
      • Unifi 4.0 Release Notes
      • Unifi 3.1 Release Notes
      • Unifi 3.0 Release Notes
      • Unifi 2.2 Release Notes
      • Unifi 2.1 Release Notes
      • Unifi 2.0 Release Notes
    • Install or Upgrade
      • Global Utility
      • Hotfix
  • Configure
    • Integration Designer
    • Processes
    • Integrations
    • Connections
    • Messages
    • Message Scripts
    • Fields
    • Field Maps
    • Response Actions
    • Event Actions
    • Datasets
      • Create a New Dataset
      • Dataset Extras
    • Polling
      • Pollers
      • Poll Processors
    • Administration
      • Activity Logs
      • Data Stores
      • Properties
      • Scheduled Scripts
      • System Logs
    • Attachments
      • Extracting Attachments
      • Fetching Attachments
      • Embedded Attachments
    • Scripting
      • Snippets
      • Variables
    • Documentation
    • How to guides
      • How to Handle Attachments
        • Message
        • Scripted REST Resource
        • Test AddAttachment
      • How to Manually Close a Bond
      • How to Poll for Large Response Payloads
      • How to Setup an OAuth Connection
        • Identity Provider Instance
        • Identity Consumer Instance
        • OAuth Refresh Token Job
      • How to Setup Heartbeat Messages
  • Deploy
    • Package
    • Instance Clone
  • Operate
    • Bonding
      • Bonds
      • Bonded Attachments
    • Transport
      • Snapshots
      • Transactions
      • Stages
      • HTTP Requests
      • Dataset Requests
      • Poll Requests
    • Error Handling
      • Integration Pause and Resume
      • Integration Repair
      • Request Retry
      • Transaction & Request Replay
      • Transaction Ignore
  • Test
    • Overview
    • Integration Test
    • Test Scenario
    • Test Scenario Data
    • Test Result
    • Test Scenario Result
    • Generating Tests
    • Running Tests
    • Exploring Results
  • Integration Guides
    • Outbound Incident Guide
      • Getting Started
      • Process
      • Integration
      • Connection
      • Create Scenario
        • CreateIncidentResponse Message
        • CreateIncidentResponse Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Response Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Conclusion
    • Bidirectional Asynchronous Incident Guide
      • Getting Started
      • Process
      • Web Service
      • Integration
      • Connection
      • Create Scenario
        • Response Message
        • CreateIncidentReceipt Message
        • CreateIncidentReceipt Fields
        • CreateIncident Message
        • CreateIncident Fields
        • Trigger
        • Test CreateIncident
      • Update Scenario
        • Receipt Message
        • UpdateIncident Message
        • UpdateIncident Fields
        • Test UpdateIncident
      • Resolve Scenario
        • ResolveIncident Message
        • ResolveIncident Fields
        • Test ResolveIncident
      • Build - Integration Level
      • Build the Other Half
        • Move the Integration
        • Reconfigure the Connections
      • Conclusion
    • Incident Update Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Message
        • UpdateIncidentInbound Message
        • UpdateIncidentInbound Fields
      • Message Identification
      • Bond Identification
        • Edit Incident Form
        • Edit CreateIncident Message
      • Test Update Poll
      • Conclusion
    • Incident Multiple Message Poller Guide
      • Polling
        • Poll Processor
        • Poller
      • Inbound Messages
        • ResolveIncidentInbound Message
        • ResolveIncidentInbound Fields
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Create Poller Guide
      • Polling
        • Connection Variables
        • Poll Processor
        • Poller
      • Messages
        • CreateIncidentInboundReceipt Message
        • CreateIncidentInboundReceipt Fields
        • CreateIncidentInbound Message
        • CreateIncidentInbound Fields
      • Build - Integration Level
      • Test Create Poll
      • Conclusion
    • Incident Parent and Child Poller Guide
      • Polling
        • Connection Variables
        • Child Poll Processor
        • Child Poller
        • Parent Poll Processor
        • Parent Poller
      • Inbound Messages
      • Testing
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
      • Conclusion
    • Incident Attachment Poller Guide
      • Polling
        • Connection Variables
        • Edit Endpoint URLs
        • Get Attachment Poll Processor
        • Get Attachment Poller
        • Select Attachments Poll Processor
        • Select Attachments Poller
        • Edit Child Poll Processor
        • Edit Child Update Poller
      • Messages
        • AddAttachmentInbound Message
      • Testing
        • Test Outbound Scenarios
        • Test CreateIncidentInbound
        • Test UpdateIncidentInbound
        • Test ResolveIncidentInbound
        • Test AddAttachmentInbound
      • Conclusion
  • Troubleshooting
    • Attachments
      • Inbound SOAP/Base64 attachments stopped working
      • New record attachments are not sent from Portal
      • Special characters in attachment file names
    • Datasets
    • Development
      • Bonding to existing records
      • Copying an existing Unifi trigger rule doesn't work
      • Duplicate messages being sent
      • Deleted records are not packaged
      • Multipart Form Data
      • Undefined error when building an integration
    • Diagnostic
    • Installation
      • Latest version of Unifi not accessible
    • Integration Responses
      • Transaction has been processed already
      • Initiating transaction not found for inbound receipt
      • Message has already been processed
      • Message ID not found
      • Message is not valid for this bond
      • Message name not recognised
      • No retry for requests with 401 response
      • Unable to identify message name from request
    • Other
      • Dynamic stage does not render
      • Duplicate bonds on Request integrations
    • Self-test
  • About
    • Quick Tour
    • Roles
    • Supported Features
    • Application Modules
    • Data Model
    • Transport Data Flow
Powered by GitBook
On this page
  • Upgrading
  • Patching

Was this helpful?

Export as PDF
  1. Install
  2. Install or Upgrade

Hotfix

PreviousGlobal UtilityNextIntegration Designer

Last updated 2 months ago

Was this helpful?

The current hotfix version is 4.3.1.4.

Unifi can be patched between releases by using a special Script Include called hotfix. If you find a bug in Unifi we may issue an update to hotfix so you can get the features you need without having to upgrade.

Upgrading

When upgrading Unifi, you can revert to the latest version of hotfix included in the upgrade. We reset hotfix with each release when the fixes become part of the main application.

Patching

We occasionally release a hotfix when minor issues are found. Simply replace the script in the hotfix Script Include with the one shown below and you will instantly have access to the fixes.

These hotfixes will be shipped as real fixes with the next version of Unifi, so make sure you have the correct hotfix for your version.

/**
 * Executes a child function corresponding to the object's type property.
 * The object is passed to the child function so methods and properties can be overridden.
 *
 * @param  {Object} obj The full class object to be patched.
 */
function hotfix(obj) {
  var type = typeof obj === 'function' ? obj.prototype.type || obj.type : obj.type;
  if (type && typeof hotfix[type] === 'function') {
    hotfix[type](obj);
  }
}

hotfix.version = '4.3.1.4';

hotfix.TransactionInbound = function(TransactionInbound) {
  TransactionInbound.prototype.prepareForReplay = function prepareForReplay(c) {
    c.is_replay = true;
    if (c.message.isCreate()) {
      c.bond.isNew(true); // for bond condition
    }
    c.target = c.bond.getTarget();
  };

  TransactionInbound.prototype.saveSnapshotToStage = function saveSnapshotToStage(c) {
    if (c.snapshot) {
      c.snapshot.commit();
      c.stage.setValue('snapshot', c.snapshot.getUniqueValue());
    }
    c.stage.commit();
  };
};

hotfix.Dataset = function(Dataset) {
  Dataset.prototype.getRecords = function getRecords() {
    var data = new GlideRecord(this.getValue('table'));
    if (this.getElement('advanced') == true) {
      this.evaluateAdvancedQuery(data);
    } else if (this.hasValue('query_condition')) {
      data.addEncodedQuery(this.getValue('query_condition'));
    }

    if (this.query_start) {
      data.addQuery('sys_updated_on', '>', this.query_start);
    }
    if (this.query_end) {
      data.addQuery('sys_updated_on', '<=', this.query_end);
    }
    if (this.query_from) {
      data.addQuery('sys_id', '>=', this.query_from);
    }

    data.orderBy('sys_id');
    data.setLimit(parseInt(this.getValue('max_rows'), 10) + 1);

    ws_console.logQuery(data);

    this.last_successful_time = this.query_end || new GlideDateTime();

    return data;
  };

  Dataset.prototype.evaluateAdvancedQuery = function evaluateAdvancedQuery(record) {
    this._record.query_script += ';true;';
    
    var result = utils.evaluateScript(this.getRecord(), 'query_script', {
        current: record,
        dataset: this.getRecord()
    });
    if (result.error) {
        throw 'Error evaluating advanced query script: ' + result.error;
    }
  };

  Dataset.execute = function execute(dataset_id, type) {
    var dataset = Dataset.getInstance(dataset_id);
    var config = dataset.getConfig();
    var connection = Connection.getActive(config, dataset.getValue('integration'));
    if (!connection.isValidRecord()) {
      _console.info('Dataset execution cancelled; no active connection.');
      return new DatasetRequest(config);
    }

    try {
      return DatasetRequest.send(dataset, type || "Delta");
    } catch (e) {
      ActivityLog.setDocument('x_snd_eb_dataset', dataset);
    }
  };
};

hotfix.DatasetRequest = function(Dataset) {
  DatasetRequest.prototype.insertNext = function insertNext(next_id) {
    var dataset = this.getDataset();
    var request = new DatasetRequest(this.getConfig());
    var number, query_end;

    request.initialize();
    request.setDataset(dataset);
    request.setDirection('Outbound');
    request.setType(this.getValue('type'));
    request.setValue('query_from', next_id);

    // show the batch by extending the number
    number = this.getValue('number');
    number = utils.partialIncrement(number, 1, 1);
    request.setValue('number', number);

    // prevent infinite exports by fixing the query time
    query_end = dataset.isFixedQueryTime() ? new GlideDateTime(this.getValue('query_end')) : new GlideDateTime();
    request.setValue('query_start', new GlideDateTime(this.getValue('query_start')));
    request.setValue('query_end', query_end);

    request.setReady();
    request.commit();
    return request;
  };
};

hotfix.utils = function (utils) {
  utils.DEBUG_CORE = _console.DEBUG_TRACE = gs.getProperty('x_snd_eb.snd_console.debug.trace') == 'true';
};

hotfix._console = function(_console) {
  _console.PROPERTY_PREFIX = 'x_snd_eb.snd_console.';
  _console.DEBUG = gs.getProperty('x_snd_eb.snd_console.debug') == 'true';
  _console.DEBUG_TRACE = utils.DEBUG_CORE = gs.getProperty('x_snd_eb.snd_console.debug.trace') == 'true';

  _console._wrapFunction = function _wrapFunction(fn, fn_name, options) {
    var fn_wrapper;

    fn_name = fn_name || _console._getType(fn);

    // This function has been wrapped - i.e. prototype inheritance
    if (fn.$c_display) {
      fn_wrapper = function run_decorated_parent() {
        return fn.apply(this, arguments);
      };
      fn_wrapper.$c_display = fn.$c_display;

      if (options.parent_name) {
        if (fn_wrapper.$c_display.indexOf(options.parent_name) === 0) {
          fn_wrapper.$c_display = '{unknown}~' + fn_wrapper.$c_display;
        } else {
          fn_wrapper.$c_display = options.parent_name + '~' + fn_wrapper.$c_display;
        }
      }
      return fn_wrapper;
    }

    fn_wrapper = function run_decorated() {
      var name = _console._getName(this, fn_name),
        ret, args, scope, e;

      if (fn.$c_private) {
        name += '#private';
      }

      try {
        args = Array.prototype.slice.call(arguments);
        args.unshift(name);
        scope = _console.enterScope.apply(_console, args);
        scope.inside_try = true; // we are in a try/catch - helps with error reporting
        ret = fn.apply(this, arguments);
      } catch (ex) {
        if (!_console.has_error) {
          _console.error(ex, [], name);
          _console.has_error = true;
        }
        _console.leaveScope('[throwing ' + (ex && ex.name ? ex.name : typeof ex) + ']');
        throw ex;
      }
      return _console.leaveScope(ret, fn.$c_private);
    };

    // store the full name on the function
    if (options.parent_name) {
      fn_wrapper.$c_display = options.parent_name + (options.is_static ? '::' : '.') + fn_name;
    } else {
      fn_wrapper.$c_display = fn_name;
    }
    return fn_wrapper;
  };

};

hotfix.Bond = function (Bond) {
  Bond.prototype.canCreateTest = function () { return true; };
};

hotfix.BondedAttachment = function (BondedAttachment) {
  BondedAttachment.deleteAttachment = function deleteAttachment(attachment_id) {
    var grd = new GlideRecord('sys_attachment');
    if (grd.get(attachment_id)) {
      grd.deleteRecord();
    } else {
      ws_console.info('Attachment with sys_id %0 not found.', [attachment_id]);
    }
  };
};

hotfix.Snapshot = function (Snapshot) {
  Snapshot.prototype.setOutbound = function setOutbound() {
    if (this.isValid()) this.setValue('direction', 'Outbound');
  };
  
  Snapshot.prototype.setInbound = function setInbound() {
    if (this.isValid()) this.setValue('direction', 'Inbound');
  };
};

hotfix.IntegrationComponentList = function (IntegrationComponentList) {
  IntegrationComponentList.prototype.getConnections = function getConnections() {
    function modifier(grd, item) {
      var url;
      if (item.direction == 'Inbound') {
        item.subtitle = gs.getMessage('Inbound only');
      } else if (!grd.endpoint_url.nil()) {
        gs.include('URL'); // Overwrite native URL for Yokohama
        item.subtitle = new URL(grd.endpoint_url).getHost();
      } else {
        item.subtitle = gs.getMessage('No endpoint configured');
      }
    }
    return this.getItems('x_snd_eb_connection', 'integration=' + this.integration_id + '^ORDERBYname', modifier);
  };
};