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:27 AM
Ok i think there is some issue with your addQuery, i can not see memStatus field defined, please validate addQuery once how many record you getting u=just with the addQuery
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:35 AM
Hi @Ankita Kolhe ,
I tried your issues on my PDI and I hope this works for you too
Please refer below script
var cd = new GlideAggregate('choice_definitions');
cd.addQuery('field_name=Membership Status^choice_valueIN' + memStatus);
cd.addAggregate('MIN', 'order');
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);
}
After removing cd.setGroup(false); it is working fine for me
Please mark my answer correct and helpful if it works for you
Thanks and Regards
Sarthak