need ticket count for payload output 200

ShaibaazFaheem
Tera Contributor

Hello Community!

 

I wanted to count the number of tickets where the Payload output status is 200 and the ticket hop was routed to a specific group.

 

Any help is much appreciated.

6 REPLIES 6

Matthew_13
Mega Sage

Hi Buddy,

You’ll need to confirm where “Payload output status” is stored and what you mean by “ticket hop”.

If “ticket hop” = the ticket was ever routed to that group (assignment group changed)

Use sys_audit to count distinct tickets that had assignment_group changed to the target group, then filter those tickets by payload status = 200.

Hop to group (count distinct tickets):

  • Table: sys_audit

  • Conditions:

    • tablename = incident (or your ticket table)

    • fieldname = assignment_group

    • newvalue = <target group sys_id>

  • Aggregate: COUNT DISTINCT documentkey

Then apply your payload filter:

  • If status is on the ticket (ex: u_payload_status = 200), just add that to the ticket query.

  • If status is in a REST/integration log table, you’ll need to join (DB view) or do a 2-step script (pull ticket sys_ids where status=200, then intersect with the audit results).

If you only mean “currently assigned to that group”

Then it’s simpler—just run a report/aggregate on the ticket table with:

  • payload_status = 200

  • assignment_group = <target group>

But that doesn’t prove it “hopped,” only that it’s assigned there now.

 

@ShaibaazFaheem - Please mark Accepted Solution and Thumbs Up if you found Helpful!

MJG

Deepak Shaerma
Mega Sage

Hi @ShaibaazFaheem 

Use this script:

// Replace 'u_integration_log' with your actual table name
var agg = new GlideAggregate('u_integration_log'); 

// 1. Condition: Payload output status is 200
// Ensure 'u_payload_status' is the correct backend name of your field
agg.addQuery('u_payload_status', '200'); 

// 2. Condition: Routed to specific group
// Replace 'Network Team' with the exact name of the group, or use the sys_id
agg.addQuery('u_assignment_group.name', 'Network Team'); 

// 3. Calculate the count
agg.addAggregate('COUNT');
agg.query();

if (agg.next()) {
    var count = agg.getAggregate('COUNT');
    gs.info('Number of tickets with Status 200 and Group Routing: ' + count);
}

 
Happy to help! ‌‌
To help others in the community find this solution, kindly mark this response as the Correct Answer ‌‌ and Helpful‌‌.
Warm Regards,
Deepak Sharma
Community Rising Star 2025

Ankur Bawiskar
Tera Patron

@ShaibaazFaheem 

your question is not clear.

It would be better if you share complete business requirement along with screenshots

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Its_Azar
Kilo Sage

Hi there @ShaibaazFaheem 

 

Can you be lil more specific

 

I believe that u mean you want to find out all incoming payloads which has status code 200? 

and assigned to a particular group, right?

 for this u can create a report on the table, filtering assignment group and payload status. (fields)

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.