- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 01:51 PM
Hi Guys,
Need some help...
I created a flow action to get user's telecom asset(s). The action is very simple and it works. It returns the sys_id of the assets:
var MobilityUtil = Class.create();
MobilityUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getDevice: function() {
try {
var sysID = this.getParameter('sysparm_id');
var user_GR = new GlideRecordSecure('sys_user');
user_GR.addQuery('sys_id', sysID);
user_GR.query();
user_GR.next();
var inputs = {};
inputs['user'] = user_GR; // GlideRecord of table: sys_user
var result = sn_fd.FlowAPI.getRunner().action('x_rrdu2_mobility.get_telecom_asset').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
var device = outputs['device']; // String
gs.info('Device = ' + device);
return device;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
},
type: 'MobilityUtil'
});
How do I return the list of devices? I am currently getting Device = [object GlideRecord]
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 05:21 PM
Hi @JLeong
I hope this helps -
var MobilityUtil = Class.create();
MobilityUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getDevice: function() {
try {
var sysID = this.getParameter('sysparm_id');
var user_GR = new GlideRecordSecure('sys_user');
user_GR.addQuery('sys_id', sysID);
user_GR.query();
user_GR.next();
var inputs = {};
inputs['user'] = user_GR; // GlideRecord of table: sys_user
var result = sn_fd.FlowAPI.getRunner().action('x_rrdu2_mobility.get_telecom_asset').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
var devices = [];
for (var i = 0; i < outputs['device'].length; i++) {
devices.push(outputs['device'][i].sys_id);
}
// Print Devices:
for (var i = 0; i < devices.length; i++) {
gs.info('Device ' + i + ': ' + devices[i]);
}
return devices;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
},
type: 'MobilityUtil'
});
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 05:21 PM
Hi @JLeong
I hope this helps -
var MobilityUtil = Class.create();
MobilityUtil.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getDevice: function() {
try {
var sysID = this.getParameter('sysparm_id');
var user_GR = new GlideRecordSecure('sys_user');
user_GR.addQuery('sys_id', sysID);
user_GR.query();
user_GR.next();
var inputs = {};
inputs['user'] = user_GR; // GlideRecord of table: sys_user
var result = sn_fd.FlowAPI.getRunner().action('x_rrdu2_mobility.get_telecom_asset').inForeground().withInputs(inputs).run();
var outputs = result.getOutputs();
// Get Outputs:
var devices = [];
for (var i = 0; i < outputs['device'].length; i++) {
devices.push(outputs['device'][i].sys_id);
}
// Print Devices:
for (var i = 0; i < devices.length; i++) {
gs.info('Device ' + i + ': ' + devices[i]);
}
return devices;
} catch (ex) {
var message = ex.getMessage();
gs.error(message);
}
},
type: 'MobilityUtil'
});
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2023 04:14 AM
I appreciate your help, Tushar! Thank you!