related list not filtering
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 04:00 PM
Hi All,
I hope everything is ok at your end.
Situation
I created a related list between "business application" and "Catalog Tasks" (dont want to use the OOB one).
Relationship details:
Applies to table = cmdb_ci_business_app
Queries from: sc_task
Query: "current.addQuery('cmdb_ci', parent.sys_id);
this works fine. However, i would like to add one more filter and i dont know how to do it.
I would like to also filter where the catalog task is for a specific "item" (service catalog item)/
how do i do that?
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2024 12:36 PM
Hi @El Cuchi
Try this way
var orQuery = glideRecord.addQuery('risk', 1);
orQuery.addOrCondition('risk', 2);
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2024 01:50 PM
Hey! Try this.
You can add multiple filters using 'addQuery' or 'addOrCondition'
var getTasks = current.addQuery('cmdb_ci', parent.sys_id);
getTasks.addQuery('request_item.cat_item', 'SYSID_OF_YOUR_ITEM'); //catalog item name is on the request_item table
//if you want to use OR condition
var getTasks = current.addQuery('cmdb_ci', parent.sys_id);
getTasks.addOrCondition('request_item.cat_item', 'SYSID_OF_YOUR_ITEM');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 06:07 AM
current.addQuery (assuming current is an instance of GlideRecord) returns an object of "type" GlideQueryCondition.
So variable getTasks is an instance of GlideQueryCondition.
But instances of GlideQueryCondition have no addQuery method.
Instances of GlideQueryCondition have only two methods: addCondition and addOrCondition (as @Dr Atul G- LNG too suggested).
But no addQuery.
Thus your suggestion:
getTasks.addQuery('request_item.cat_item', 'SYSID_OF_YOUR_ITEM');
will not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2024 05:24 PM
You can call current's addQuery method multiple time:
current.addQuery('cmdb_ci', parent.sys_id);
current.addQuery('request_item.cat_item', '<sys_id of the desired Catalog Item>');