API to get all tickets created on behalf of a user

Beena1
Kilo Contributor

Hello geeks,

I need to query all active tickets of a user with REST API. Currently, I am using task table to get all tickets where opened_by.email = {user email id}. It works just fine for the tickets created by that user, but I also need to pull the tickets that were created by someone else on behalf of that user. Is there a way, I can get those tickets as well from the task table?

I know that in incident table, 'caller' is the field, which holds the user on whose behalf the ticket has been created, but could not get any equivalent of caller in task table. I need all types of tickets either created by user or created on behalf of that user.

Please help!

 

Thanks in advance,

Beena

 

 

 

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Beena,

caller is the user for whom the incident is raised. Are you having any field on task to store the On Behalf of user?

If yes then you can have or condition opened_by.email = {user email id} or on_behalf_of.email = {user email id}

Regards
Ankur

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

Giles Lewis
Giga Guru

Hi Beena.

There is no equivalent field field to caller_id in the task table. Sometimes customers will add a custom field to the task table (e.g. u_affected_user or u_on_behalf_of) to address this requirement.

If you do not have such a custom field, then you will need to run multiple REST queries (one per table) to find all the records.

Please mark this reply as helpful and/or correct if applicable.