How to get value of a field in glideaggregate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:05 AM
Hi Community,
How to get value of a field in glideaggregate?
code:-
var cd=new GlideAggregate('choice_definitions');
cd.addQuery('field_name=Membership Status^choice_valueIN'+memStatus);
cd.addAggregate('MIN', 'order');
cd.setGroup(false);
cd.query();
while(cd.next()){
var test=cd.choice_value;
gs.info('Most recent Incident Created Date = ' + cd.getAggregate('MIN', 'order'));
gs.info('test: '+test);
}
output-
Most recent Incident Created Date = 420
test:
Could someone pls help on this?
Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:08 AM
you're trying to access the choice_value field directly from the GlideAggregate object, but GlideAggregate doesn't provide direct access to field values like that. Instead, you need to use the getValue() method to retrieve the value of a field. Please try with below code:
var cd = new GlideAggregate('choice_definitions');
cd.addQuery('field_name=Membership Status^choice_valueIN' + memStatus);
cd.addAggregate('MIN', 'order');
cd.setGroup(false);
cd.query();
while (cd.next()) {
var test = cd.getValue('choice_value');
gs.info('Most recent Incident Created Date = ' + cd.getAggregate('MIN', 'order'));
gs.info('test: ' + test);
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:16 AM - edited 04-15-2024 02:17 AM
Are you sure 'choice_value' field present on the table choice_definitions table also validate if value is present in the field.Please validate once
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2024 02:19 AM
Yes, the field and value both are present in choice_definition table.