Getting the value of Catalog from Approval table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 07:04 AM
Hi All
For the RITM records in sysapproval_approver table, I'm trying to get the value of catalog that the item belongs to.
I'm using 'sysapproval.cat_item.sc_catalogs' (taskGR.addQuery('sysapproval.cat_item.sc_catalog','catalogs');) to get this value but that does not give me the correct value I guess because there is no change in the number of records queried after applying this filter.
Can anyone help me to know what query should be used to get the catalog name from sc_catalog table for a given approval record.
Thanks,
Nisha
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 10:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 10:29 AM
Also what is x a sys_id of. That seems to be you would be getting the sys_id of a specific approval and not the sys_id from the approval_for which would be the sys_id of your request item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-29-2018 10:53 AM
Hey Brian, x is a specific item I was using for testing. I was using the id to query from the REQ. It was a specific record that I could use for testing. If the approval record is an RITM then dot-walking is sufficient:
sysapproval.cat_item.sc_catalog.getDisplayValue()
A general query on the whole sysapproval_approver table:
gr.addQuery('sysapproval.cat_item.sc_catalog', <catalog_id>);
I might even add an encoded query to find only RITMs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 06:13 AM
I'm using an encoded query as
taskGR.addEncodedQuery('state=requested^ref_sysapproval.sys_class_name=sc_req_item^ref_sysapproval.ref_cat_item.sc_catalogsIN' + catalogs + '^approver=' + userId + '^ORu_delegatesCONTAINS' + userId);
but even this is not giving the result.
Also, I have to put another query to filter on a filed of type choice in Requested Item table.
The field is u_request_type
so my code looks like
var taskGR = new GlideRecord('sysapproval_approver');
taskGR.addQuery('^approver=' + userId + '^ORu_delegatesCONTAINS' + userId);
taskGR.addQuery('state', 'requested');
taskGR.addQuery('sysapproval.sys_class_name', 'sc_req_item');
taskGR.addQuery('sysapproval.u_request_type','PT');
taskGR.query();
PT is one of the values in the choice, but the last line of code which queries the u_request_type field in sc_req_item table does not work.
I'm trying to get the value after quey
var reqtype = taskGR.sysapproval.u_request_type.getDisplayValue();
or
var reqtype = taskGR.sysapproval.u_request_type.label;
but this returns undefined.
So, the question is how do we query for field of type choice.
Regards,
Nisha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2018 07:50 AM
Couple of things:
taskGR.addQuery('^approver=' + userId + '^ORu_delegatesCONTAINS' + userId);
looks like it should be an encodedQuery
taskGR.addEncodedQuery('^approver=' + userId + '^ORu_delegatesCONTAINS' + userId);
For PT, try getValue(). The choice has a value that may be different than the displayed value.
var PT = current or taskGR .getValue('sysapproval.u_request_type');
then query with taskGR.addQuery('sysapproval.u_request_type', PT); //no quotes on PT