Script to Retrieve User-Created Incident and RIMT Numbers

MaramA
Tera Contributor

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.

 
 

MaramA_3-1719723317344.png

 

MaramA_0-1719723269517.png

 

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

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.

View solution in original post

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@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)

@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.

@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.

SN_Learn
Kilo Patron
Kilo Patron

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.