Getting values from a parameter in an event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 04:59 AM
I've got the following scheduled job that collects information about business applications and potential users, whose end date is approaching:
However, when I preview my notification, I'm getting sys IDs instead of the values I need:
I was wondering if somebody could explain how I get the required values so that they are displayed correctly in my email.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 05:07 AM - edited 01-08-2024 05:24 AM
Hello @matthew_hughes
Please make below changes-
var grOwnership = new GlideRecord('cmdb_ci_business_app');
grOwnership.addEncodedQuery('u_business_owner.active=true^u_business_owner.u_end_dateRELATIVELT@dayofweek@ahead@30^NQu_cmdb_data_steward.active=true^u_cmdb_data_steward.u_end_dateRELATIVELT@dayofweek@ahead@30^NQu_custodian.active=true^u_custodian.u_end_dateRELATIVELT@dayofweek@ahead@30');
grOwnership.query();
ownersLoop = [];
while (grOwnership.next()) {
//Get the value of the Divisional Application Owner and convert it to a string
var divisionalApplicationOwner = grOwnership.u_business_owner + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(divisionalApplicationOwner) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(divisionalApplicationOwner);
gs.eventQueue('lbg.notify.reassign_new_owner_DAO', grOwnership, grOwnership.u_business_owner.manager.toString(), grOwnership.u_business_owner.getDisplayValue());
}
//Get the value of the Business Application Steward and convert it to a string
var businessApplicationSteward = grOwnership.u_cmdb_data_steward + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(businessApplicationSteward) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(businessApplicationSteward);
gs.eventQueue('lbg.notify.reassign_new_owner_BAS', grOwnership, grOwnership.u_cmdb_data_steward.manager.toString(), grOwnership.u_cmdb_data_steward.getDisplayValue());
}
//Get the value of the Technical Application Owner and convert it to a string
var technicalApplicationOwner = grOwnership.u_custodian + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(technicalApplicationOwner) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(technicalApplicationOwner);
gs.eventQueue('lbg.notify.reassign_new_owner_TAO', grOwnership, grOwnership.u_custodian.manager.toString(), grOwnership.u_custodian.getDisplayValue());
}
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 05:14 AM
u_business_owner field on cmdb_ci_business_app table is reference to user and you are pushing the sysId
Do this change in script for 3 lines and it will work
//User is an Application Service Steward for an Application Service where Status is not Disposed, and user's Manager is Active
var grOwnership = new GlideRecord('cmdb_ci_business_app');
grOwnership.addEncodedQuery('u_business_owner.active=true^u_business_owner.u_end_dateRELATIVELT@dayofweek@ahead@30^NQu_cmdb_data_steward.active=true^u_cmdb_data_steward.u_end_dateRELATIVELT@dayofweek@ahead@30^NQu_custodian.active=true^u_custodian.u_end_dateRELATIVELT@dayofweek@ahead@30');
grOwnership.query();
ownersLoop = [];
while (grOwnership.next()) {
//Get the value of the Divisional Application Owner and convert it to a string
var divisionalApplicationOwner = grOwnership.u_business_owner + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(divisionalApplicationOwner) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(divisionalApplicationOwner);
gs.eventQueue('lbg.notify.reassign_new_owner_DAO', grOwnership, grOwnership.u_business_owner.manager.toString(), grOwnership.u_business_owner.getDisplayValue());
}
//Get the value of the Business Application Steward and convert it to a string
var businessApplicationSteward = grOwnership.u_cmdb_data_steward + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(businessApplicationSteward) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(businessApplicationSteward);
gs.eventQueue('lbg.notify.reassign_new_owner_BAS', grOwnership, grOwnership.u_cmdb_data_steward.manager.toString(), grOwnership.u_cmdb_data_steward.getDisplayValue());
}
//Get the value of the Technical Application Owner and convert it to a string
var technicalApplicationOwner = grOwnership.u_custodian + '';
//If there is already an existing entry, remove the duplicate entry
if (ownersLoop.indexOf(technicalApplicationOwner) == -1) {
//Add the single entry to the ownersLoop
ownersLoop.push(technicalApplicationOwner);
gs.eventQueue('lbg.notify.reassign_new_owner_TAO', grOwnership, grOwnership.u_custodian.manager.toString(), grOwnership.u_custodian.getDisplayValue());
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 08:15 AM
any update to this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader