Interview Help- New To ServiceNow

vidishaagarwal5
Tera Contributor

Hi Team,

 

I have been asked to write the code align with the Below Image..

I have used glideAggrette.. But state is showing like 2,3 but not showing in display name and this bog space how to give.

My Code :-

var x=new GlideAggregate('incident');
x.addAggregate('COUNT','state');
x.query();
while(x.next()){
gs.print(x.state.+grIncident. getAggregate('COUNT','state'));
}
not getting the below Output

vidishaagarwal5_0-1755766208076.png


@David my Post is always getting in unapproved phase. Help me

 

1 ACCEPTED SOLUTION

Ravi Gaurav
Giga Sage
Giga Sage

Hi @vidishaagarwal5 

You need to change the Code to the below code

gs.print('State\\tIncident Count');
var x=new GlideAggregate('incident');
x.addAggregate('COUNT','state');
x.query();
while(x.next()){
gs.print(x.state. getDisplayValue()+'\t'+x. getAggregate('COUNT','state'));
}

This will Help

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

6 REPLIES 6

@vidishaagarwal5 

 

As per community guidelines, you can accept more than one answer as solution. If my response helped you, please mark it as helpful and accept the solution.

 

Thanks,

Bhuvan

Ravi Gaurav
Giga Sage
Giga Sage

@David  and @Dan Bruhn   can you help her . 

Thanks in Advance !!

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/