- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2021 02:27 PM
Hey all,
I'm currently trying to tie some Service Catalog variables to two System Properties that I wrote called "rm.lead_engineer_valid_short_descriptions" and "rm.lead_engineer_project_tasks" - both of which I'm referencing in a Script Include. However, after some testing with the Reference Qualifier, I keep getting "undefined" errors in my code - the weird thing is that it's got nothing to do with the properties themselves, because I make the same calls in other situations without issue. Here's my code:
IP_RM_Utilities.getLeadEngineerDescriptions = function() {
var descriptionsList = [];
var projectTaskIDs = gs.getProperty('rm.lead_engineer_project_task_ids'); // This is undefined in Reference Qualifiers.
gs.log('GetProperty Result: ' + gs.getProperty('rm.lead_engineer_valid_short_descriptions'), 'IP_RM_Utilities');
var projectTask = new GlideRecord('pm_project_task');
projectTask.addQuery('sys_id', 'IN', projectTaskIDs);
projectTask.query();
// Add each Project Task Description to the list.
if (!projectTask.hasNext()) gs.logError('[isLeadEngineerDescription] ERROR: Could not find any Project Tasks with a sys_id in: ' + projectTaskIDs, 'IP_RM_Utilities');
while (projectTask.next()) {
if (projectTask.getValue('short_description') != '') descriptionsList.push(projectTask.getValue('short_description'));
}
// Add Short Descriptions System Property for edge case protection.
var shortDescriptionsString = gs.getProperty('rm.lead_engineer_valid_short_descriptions'); // This is also undefined in Reference Qualifiers.
var shortDescriptions = shortDescriptionsString.split(',');
var returnList = descriptionsList.concat(shortDescriptions);
return returnList.toString();
};
When I call this function in a background script, I get a valid response. But when I call this in a Reference qualifier as such, I get gs.getProperty() as 'undefined':
Does anyone know how to circumvent this/why this is the case?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2021 02:29 PM
On line 4 not showing up, that was just me not including it in the log screenshot - the result always looks like this, though:
This is the result I got when swapping out all the gs.getProperty() calls for (new GlideSystem).getProperty() - code currently looks like this:
IP_RM_Utilities.getLeadEngineerDescriptions = function() {
var descriptionsList = [];
var projectTaskIDs = (new GlideSystem()).getProperty('rm.lead_engineer_project_task_ids'); // This is undefined in Reference Qualifiers.
gs.log('GetProperty Result: ' + (new GlideSystem()).getProperty('rm.lead_engineer_valid_short_descriptions'), 'IP_RM_Utilities');
var projectTask = new GlideRecord('pm_project_task');
projectTask.addQuery('sys_id', 'IN', projectTaskIDs);
projectTask.query();
// Add each Project Task Description to the list.
if (!projectTask.hasNext()) gs.logError('[isLeadEngineerDescription] ERROR: Could not find any Project Tasks with a sys_id in: ' + projectTaskIDs, 'IP_RM_Utilities');
while (projectTask.next()) {
if (projectTask.getValue('short_description') != '') descriptionsList.push(projectTask.getValue('short_description'));
}
// Add Short Descriptions System Property for edge case protection.
var shortDescriptionsString = gs.getProperty('rm.lead_engineer_valid_short_descriptions'); // This is also undefined in Reference Qualifiers.
var shortDescriptions = shortDescriptionsString.split(',');
var returnList = descriptionsList.concat(shortDescriptions);
return returnList.toString();
};
One thing I did notice, however, is that this situation does seem to work for a Multi-Row Variable Set where the Reference Qualifier is set to 'Advanced' instead of 'Simple' - swapping 'Use Reference Qualifier' to 'Advanced' on the original error case seemed to make this work. Really strange that it doesn't work with Simple Reference Qualifiers, however...
Thanks for the response, Drew! Helped get me on the right path 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2021 02:47 PM
I notice line 4 does not show up in your log statements that you show. Is that an oversite or did it really not run.
Also gs = GlideSystem global object and may not exist when your ref qual code runs. I thought it did but to be sure try using (new GlideSystem()).getProperty() and see if it errors.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2021 02:29 PM
On line 4 not showing up, that was just me not including it in the log screenshot - the result always looks like this, though:
This is the result I got when swapping out all the gs.getProperty() calls for (new GlideSystem).getProperty() - code currently looks like this:
IP_RM_Utilities.getLeadEngineerDescriptions = function() {
var descriptionsList = [];
var projectTaskIDs = (new GlideSystem()).getProperty('rm.lead_engineer_project_task_ids'); // This is undefined in Reference Qualifiers.
gs.log('GetProperty Result: ' + (new GlideSystem()).getProperty('rm.lead_engineer_valid_short_descriptions'), 'IP_RM_Utilities');
var projectTask = new GlideRecord('pm_project_task');
projectTask.addQuery('sys_id', 'IN', projectTaskIDs);
projectTask.query();
// Add each Project Task Description to the list.
if (!projectTask.hasNext()) gs.logError('[isLeadEngineerDescription] ERROR: Could not find any Project Tasks with a sys_id in: ' + projectTaskIDs, 'IP_RM_Utilities');
while (projectTask.next()) {
if (projectTask.getValue('short_description') != '') descriptionsList.push(projectTask.getValue('short_description'));
}
// Add Short Descriptions System Property for edge case protection.
var shortDescriptionsString = gs.getProperty('rm.lead_engineer_valid_short_descriptions'); // This is also undefined in Reference Qualifiers.
var shortDescriptions = shortDescriptionsString.split(',');
var returnList = descriptionsList.concat(shortDescriptions);
return returnList.toString();
};
One thing I did notice, however, is that this situation does seem to work for a Multi-Row Variable Set where the Reference Qualifier is set to 'Advanced' instead of 'Simple' - swapping 'Use Reference Qualifier' to 'Advanced' on the original error case seemed to make this work. Really strange that it doesn't work with Simple Reference Qualifiers, however...
Thanks for the response, Drew! Helped get me on the right path 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2021 02:49 PM
So I'm a little confused, did using (new GlideSystem()).getProperty() get it to work and you just found that changing the type of the ref qual to advanced also did the job without changing the code?