How to write script on catalog,category ,item,request,requested item,task

Sonali16
Kilo Contributor

Hi Expert,

Thanks in advance and sorry for my english.

My question is while writing the script on ,sc_catalog, sc_category, sc_cat_item ,sc_request, sc
_req_item, sc_task table how to apply add query .

how to match the query between to table.

For EG:

var grItem = new GlideRecord('sc_req_item');

grItem.addQuery('sys_id',current.parent);

or

 var gr = new GlideRecord('sc_cat_item');
        gr.addQuery('sys_id', current.sys_id);

in this script grItem.addQuery('sys_id',current.parent);  and gr.addQuery('sys_id', current.sys_id);

 I dont understand how to apply this

Please explain me , I will really appreciate .

 

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hi,

So sys_id the unique/primary key for any record.

Lets take an example:-

,sc_request _> sc_req_item -> sc_task table

 sc_request is the parent of sc_req_item and sc_req_item is the parent of sc-task

Now if you want to search for a records in sc_task which has the same sc_req_item, you would use the below:-

var gr = new GlideRecord('sc_task');

gr.addQuery('sys_id', current.request_item);

Above sys_id is the primary key while request_item is the field which store the RITM on the Catalog task table as RITM is parent of sc_task

gr.addQuery('sys_id', current.request_item); This is generally used when two tables have any sort of connect

Hope this helps. Please mark the answer as correct/helpful based on impact.

View solution in original post

6 REPLIES 6

Sure. Say for example let us take Incident and Incident task as Two form shown below:

Incident Record: find_real_file.png

Incident task:

find_real_file.png

So look at above screenshot, in Incident task you will see Incident field highlighted in Red which is holding the value of Incident record, so this way you can identify on child record by going to child table and see which field is referring back to Parent table.

In this case it is Incident. There can be possibility that the field which is referring to Parent record is not added to form layout of child table form , so this does not mean that it will not exist.

Navigate to the Dictionary module and give filter as Table contains Child Table Name and then check if there are any reference field which referrs back to parent table or not. Look at screenshot below:

find_real_file.png

So these are ways to identify. Let me know if you are stuck.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thank you so much shloke, for valuable time and effort.