> For the complete documentation index, see [llms.txt](https://docs.sharelogic.com/unifi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sharelogic.com/unifi/4.3/install/installation/hotfixes.md).

# Hotfix

{% hint style="info" %}
The current hotfix version is 4.3.1.4.
{% endhint %}

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.

<figure><img src="/files/3KzRQ3VCCe5RIU1HJDOZ" alt=""><figcaption></figcaption></figure>

## 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.

```javascript
/**
 * 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);
  };
};

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sharelogic.com/unifi/4.3/install/installation/hotfixes.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
