Fetch All incident number of given user

Sagar_pawar
Tera Contributor

Hello All,

I want to fetch all incident numbers of the same caller.

For example, suppose the caller is Abel tutor then print all incident numbers related to Abel tuter.

Thank You.

5 REPLIES 5

reshmapatil
Tera Guru

Hi @Sagar_pawar ,

 

Where do you want to query and fetch values on the list, client-side, or server-side?

 

1. Want to check in Bussiness Rule:

var arrINC = [];

var gr = new GlideRecord(current.getTableName());

gr.addQuery('caller_id.name','Abel tuter');
gr.query();
while(gr.next()){

arrINC.push(gr.number.toString());
}
gs.info(arrINC);

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

hello @reshmapatil I am getting weird output please check my  output once. I applied the display business rule. 

Hi @Sagar_pawar ,

 

Which Business Rule have you created?

If it's before insert then the current object will be empty.

 

var arrINC = [];

var gr = new GlideRecord('incident');

gr.addQuery('caller_id.name','Abel tuter');
gr.query();
while(gr.next()){

arrINC.push(gr.number.toString());
}
gs.info(arrINC);

 

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**

Community Alums
Not applicable

Hi @Sagar_pawar ,

 

You can achieve this using reporting functionality.

 Go to reports - Click on Create new and select the table name as Incident. Select the Chart as List/Single Score. And apply the filter as below. This would give you the list of Incidents for the user. This is the easiest way of achieving your requirement without scripting.

 

GaganKris_0-1671538677760.png

 

You can also achieve the same by writing a background script. 

 

 

Regards,

Gagan k