How to glide record and query to exclude document (document id field) from 1 table

Bird1
Mega Sage

Hi Guys,

 

I need help. I am creating a mail script to glide the localization requested item table ('sn_lf_requested_item') but the requirement is to exclude document (document id field) from knowledge table ('kb_knowledge') . 

 

Here's some part of my mail script that trying to glide localization requested item record based on localization task and exclude document from knowledge table.

 

Any advice?

 

var gr = new GlideRecord('sn_lf_requested_item');
gr.addQuery('localization_task', current.sys_id);
gr.addQuery('document', ???); << not knowledge table
gr.query();

1 ACCEPTED SOLUTION

Omkar Kumbhar
Mega Sage

Hello @Bird1 ,

Please try using table_name in addQuery

var gr = new GlideRecord('sn_lf_requested_item');
gr.addQuery('localization_task', current.sys_id);
gr.addQuery('table_name', '!=','kb_knowledge');

gr.query();

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

View solution in original post

4 REPLIES 4

Soeren Maucher
Mega Sage

Hello @Bird1

 

the best way in my opinion to create more complex queries like "is not", "contains", "greater than" etc. is to go in the backend, filter the list as you want it and then copy the query from there. I will show you what I mean in the following screenshots: 
1. Create the Query you want in the backend on the  localization requested item table (sn_lf_requested_item😞 

SoerenMaucher_0-1677859512171.png

2. Right klick on the filter and select "Copy query"

 

SoerenMaucher_2-1677859568690.png

3. The result will be "document!=kb_knowledge"
4. Now add this to your glide record with the function "addEncodedQuery()"
5. Your Script should look like this: 

 

var gr = new GlideRecord('sn_lf_requested_item');
gr.addQuery('localization_task', current.sys_id);
gr.addEncodedQuery('document!=kb_knowledge');
gr.query();

 

 

I hope this helped. If yes, I would appreciate if you could mark this answer as "correct solution" or give a thumbs up. Thank you!


Greetings,
Sören

Unfortunately the the data type of 'document' field is document id type, I could see it stored the sys_id of record. I tried to exclude kb_knowledge but not work. You could see it still shows the record from knowledge table.

 

Bird1_0-1677860661841.png

 

Omkar Kumbhar
Mega Sage

Hello @Bird1 ,

Please try using table_name in addQuery

var gr = new GlideRecord('sn_lf_requested_item');
gr.addQuery('localization_task', current.sys_id);
gr.addQuery('table_name', '!=','kb_knowledge');

gr.query();

 

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

It seems to be workable. I am new for this Localization Table, just know that there's table_name field could help to filter. Thanks a lot.