- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:40 AM
Hi, I'm trying to get the value of a reference field from the following query but also using getValue() and getDisplayValue() i receive an undefined or null value; how can I get it out?
Here the script:
"
var req_all_sum = new GlideAggregate('requested_allocation');
req_all_sum.addAggregate('SUM', 'fte');
req_all_sum.addAggregate('SUM', 'requested_hours');
req_all_sum.addQuery('resource_plan.state','3');
req_all_sum.groupBy('resource_plan.user_resource');
req_all_sum.groupBy('resource_plan.task');
req_all_sum.groupBy('u_year_month');
req_all_sum.setQueryReferences(true);
req_all_sum.query();
while (req_all_sum.next()) {
gs.log("User " + " FTE " +req_all_sum.getAggregate('SUM', 'fte')+" hours "+ req_all_sum.getAggregate('SUM', 'requested_hours') +" Project " + req_all_sum.resource_plan);
gs.log("user: " + req_all_sum.resource_plan.user_resource.getDisplayValue()); // nothing
gs.log("user: " + req_all_sum.resource_plan.user_resource.getValue()); // undefined
gs.log(req_all_sum.u_year_month.getDisplayValue()); //here I see the value
}
"
Solved! Go to Solution.
- Labels:
-
Resource Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2017 12:10 AM
I got the values in this way
req_all_sum.getValue("resource_plan.user_resource");
req_all_sum.getValue("resource_plan.task");

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:46 AM
What do you get if you do gs.log as shown below
gs.log("user: " + req_all_sum.resource_plan.getDisplayValue()); // nothing
gs.log("user: " + req_all_sum.resource_plan.getValue()); // undefined
gs.log("user: " + req_all_sum.resource_plan.getDisplayValue()); // nothing
gs.log("user: " + req_all_sum.resource_plan.getValue()); // undefined
gs.log("user: " + req_all_sum.resource_plan.user_resource.getDisplayValue()); // nothing
gs.log("user: " + req_all_sum.resource_plan.user_resource.getValue()); // undefined
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:50 AM
I get the same result.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:51 AM
req_all_sum is your aggregate. You have two of them, fte and requested_hours. Those are the two things you can get from req_all_sum. You cannot dot-walk to other objects in the GlideRecord because it's not a GlideRecord, it's a GlideAggregate (doing completely different stuff at the database level.)
See the examples here for more insight;
http://wiki.servicenow.com/index.php?title=GlideAggregate#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2017 12:10 AM
I got the values in this way
req_all_sum.getValue("resource_plan.user_resource");
req_all_sum.getValue("resource_plan.task");