- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2024 09:58 PM
Sure, here's a revised version of your message in good English:
---
Hello,
I am trying to create a script to retrieve all the incident numbers and RIMT numbers that a user has created. I have created a related list and established a relationship between the User and Task tables. However, the code I have written is not working as expected.
I would be grateful for any help.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2024 04:45 AM
Hi @MaramA ,
Please try the below:
(function refineQuery(current, parent) {
current.addQuery('opened_by', parent.sys_id);
current.addQuery('active', true);
current.addEncodedQuery('sys_class_name=incident^ORsys_class_name=sc_req_item');
current.orderBy('number');
})(current, parent);
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2024 10:11 PM
@MaramA The query is not working as there is no caller_id field present on the task table. Either change the Queries from table to incident or change the field to opened_by (if it applies in your case)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2024 10:22 PM
@Sandeep Rajput
I need to keep the queries from the table because it includes both RITM and incident tables. The main purpose is to retrieve all tickets (incident or RITM) that have been opened by any user, so I cannot specify a particular user.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2024 12:15 AM
@MaramA Please change the query to following and see if it works for you.
current.addQuery('opened_by',parent.sys_id);
current.addQuery('active',true);
current.orderBy('number');
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2024 04:45 AM
Hi @MaramA ,
Please try the below:
(function refineQuery(current, parent) {
current.addQuery('opened_by', parent.sys_id);
current.addQuery('active', true);
current.addEncodedQuery('sys_class_name=incident^ORsys_class_name=sc_req_item');
current.orderBy('number');
})(current, parent);
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.