I want to display fields from the Alerts table in the Incidents table.

nullpo1
Tera Contributor

hi everyone

 

I want to display the event_count of the em_alert table in the incident table.

I have the following current implementations.

 

1.Create an integer custom field in the incident table

nullpo1_0-1685449046010.png

2.Script Include Create
Search for alerts from incidents and get event_count

nullpo1_1-1685449105193.png

3.Business rule Create

Update incident custom field before querying

nullpo1_2-1685449273183.png

nullpo1_3-1685449300758.png

 

It is possible to display,but I have no idea how to make it more efficient.

I would be happy to learn of other ways to do this.

please remember me.

4 REPLIES 4

Harshal Aditya
Mega Sage
Mega Sage

Hi @nullpo1 ,

 

Hope you are doing well.

 

Nice approach but updating using query BR can cause slowness and performance issue if there are multiple users interacting with the forms and if incident count is huge.

 

Hope about using a on load client script with a client callable script include. You can update the incident record in the script include.

 

Please mark this response as correct or helpful if it assisted you with your question.

Regards,
Harshal

Thanks for help @Harshal Aditya  

I understand up to the point of checking "Client Callble" and making it available to the client.
I did not understand that after this is checked, the on-load client script is used. If you could give me some more details, that would be great.

Riya Verma
Kilo Sage
Kilo Sage

 Hi @nullpo1 ,

Hope you are doing great. 

 

You can create Business rule and use below script for updating count :

var eventCount = 0;
var gr = new GlideAggregate('em_alert');
gr.addQuery('incident', current.sys_id); // Assuming you want to display the event_count for the current incident
gr.addAggregate('COUNT');
gr.query();
if (gr.next()) {
  eventCount = gr.getAggregate('COUNT');
}

current.event_count = eventCount;
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Thanks for help @Riya Verma 
Since event_count is a field in the alerts table, does that mean you are counting the number of alerts associated with the incident?
Please tell me what you mean by recounting the number instead of getting the information from the field