Getting the value of Catalog from Approval table

n20
Kilo Explorer

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

21 REPLIES 21

its there in my London person dev instance.

find_real_file.png

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.

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.

 

 

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

 

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