How to Manually Close a Bond

Some integrations will not have a Message that closes the Bond. In these situations, it is preferable to close any open Bonds manually from a business rule on the Target table, e.g. when an Incident is closed . The following business rule script will close all the Bonds for a given record:

(function executeRule(current, previous /*null when async*/) {
  var bond;
  bond = new GlideRecord('x_snd_eb_bond');
  bond.addQuery('document', '=', current.sys_id);
  bond.addQuery('state', '!=', 'Closed');
  while ( {
    bond.state = 'Closed';
})(current, previous);