Name
global.NotificationLayoutFieldGenerator
Description
Helper script to generate payload for layout field for ServiceNow push notification
Script
var NotificationLayoutFieldGenerator = Class.create();
NotificationLayoutFieldGenerator.prototype = {
initialize: function() {
},
layoutField: function(tableName, sysId, fieldName) {
var tableGR = GlideRecord(tableName);
tableGR.addQuery('sys_id', sysId);
tableGR.query();
tableGR.next();
var displayValue = tableGR.getElement(fieldName).getDisplayValue();
var payload = { "Label": displayValue };
var gr = new GlideRecord('sys_sg_ui_style');
gr.addQuery('table', tableName);
gr.addQuery('field', fieldName);
gr.query();
while (gr.next()) {
if (GlideFilter.checkRecord(tableGR, gr.condition)) {
var parser = new JSON();
var obj = parser.decode(gr.style);
payload.Style = obj;
break;
}
}
return payload;
},
type: 'NotificationLayoutFieldGenerator'
};
Sys ID
2ffdaedc77212300258da2e2c8106163