1

ServiceNow Integration: Device Order & Delay

In order to customize the Order and Delays for devices when syncing a user from ServiceNow to xMatters, you must update the 'xMattersDevice' Script Include.

  • In the xMattersDevice script, find the createDevice function.
  • Comment out the included function, the code will look like this: 
createDevice: function (name, type, ownerID) {
var device = {
name: name,
recipientType: "DEVICE",
deviceType: type,
owner: ownerID,
externalKey: [ownerID, name].join('-').replace(/ /, '-'),
externallyOwned: this.config.EXTERNALLYOWNED
};
if (this.config.DEVICE_PROVIDERS[type]) {
device.provider = this.config.DEVICE_PROVIDERS[type];
}

return device;
},
  • Then create a new function under the same name and add your custom code.
  • This is how we are doing our customized device ordering and delays: 
createDevice: function (name, type, ownerID) {
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 2017.03.22 - SMcNall/xMatters
// Add device order and delay based on device names
this.log.debug('device name: ' + name);
var device = {};
var deviceOrderDelay = true;
var deviceOrder = 1;
var deviceDelayAfter = 0;
if (deviceOrderDelay) {
if (name === 'Work Email') {
deviceOrder = 1;
deviceDelayAfter = 0;
}
if (name === 'SMS Phone') {
deviceOrder = 2;
deviceDelayAfter = 1;
}
if (name === 'Office Phone') {
deviceOrder = 3;
deviceDelayAfter = 0;
}
if (name === 'Mobile Phone') {
deviceOrder = 4;
deviceDelayAfter = 0;
}
device = {
name: name,
recipientType: "DEVICE",
deviceType: type,
sequence: deviceOrder,
delay: deviceDelayAfter,
owner: ownerID,
externalKey: [ownerID, name].join('-').replace(/ /, '-'),
externallyOwned: this.config.EXTERNALLYOWNED
};
} else {
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
device = {
name: name,
recipientType: "DEVICE",
deviceType: type,
owner: ownerID,
externalKey: [ownerID, name].join('-').replace(/ /, '-'),
externallyOwned: this.config.EXTERNALLYOWNED
};
} // ++
if (this.config.DEVICE_PROVIDERS[type]) {
device.provider = this.config.DEVICE_PROVIDERS[type];
}

return device;
},

 

 

1 comment

Please sign in to leave a comment.