How to get value of a field in glideaggregate?

Ankita Kolhe
Tera Contributor

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! 

6 REPLIES 6

@Ankita Kolhe 

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

Community Alums
Not applicable

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