client script or gliderecord script to get all the incidents whose company name is "eg."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2016 04:38 AM
I want to know the client script or glidescript to get all the incident numbers those who are having same company name or a particular company name from incident table.
plz help me find the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2016 07:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2016 08:05 AM
Probably I should give an example of an encoded query used by a glide record query:
var queryString = "active=true^company.name=eg";
var gr = new GlideRecord('incident');
gr.addEncodedQuery(queryString);
gr.query();
while (gr.next()) {
gs.log(gr.number);
}
output:
*** Script: INC0000055
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2016 07:16 AM
To get a specific company:
var inc = new GlideRecord('incident');
inc.addQuery('company', '<sys_id of company>');
inc.query();
while(inc.next()){
gs.print(inc.number);
}
To look at all companies:
var inc = new GlideRecord('incident');
inc.orderBy('company');
inc.orderBy('number');
inc.query();
while(inc.next()){
gs.print(inc.company.name + ' - ' + inc.number);
}
This gets a count :
var inc = new GlideAggregate('incident');
inc.addAggregate('COUNT', 'company');
inc.query();
while(inc.next()){
var company = inc.company.name;
var companyCount = inc.getAggregate('COUNT', 'company');
gs.print(company + ' - ' + companyCount);
}
Any of these can be run in background scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2016 09:40 AM
thanks mike,its very helpful.