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

Almost forgot, have you tried setting your query in the list view and right-clicking to get the query for an encoded query?

find_real_file.png

 

Hi Richard,

Thanks for pointing out about using encoded query for user.

about the query not working, the display value and value are same in the choice field, both PT.

Moreover I tested with 

var n = taskGR.getValue('sysapproval.u_request_type')
gs.log("test: "+n);

and in logs it shows test: null.

 

I also tested using encodedquery from list view

taskGR.addEncodedQuery('u_request_type=PT'); but still did not work.

 

Thanks,

Nisha

Nisha, 

it looks like the getvalue doesn't like dot-walking. i can try to get to the sysapproval records directly (gr.sysapproval.requested_for) or with getRefRecord. hope this works better.

 

var gr = new GlideRecord('sysapproval_approver');
gr.get('50840e3d4ff56300ffef3879b110c738');

var x = gr.sysapproval.getRefRecord();

gs.print(gr.getValue('sysapproval.requested_for'));
gs.print(x.getValue('requested_for'));
gs.print(gr.sysapproval.requested_for);

 

*** Script: null
*** Script: 6816f79cc0a8016401c5a33be04be441
*** Script: 6816f79cc0a8016401c5a33be04be441

In my case both of the queries return undefined value.

 

var x = taskGR.sysapproval.getRefRecord();


gs.log(x.getValue('u_request_type'));
gs.log(taskGR.sysapproval.u_request_type);

The only difference I see is the field type. The one I'm querying to is of type choice and a custom field.

Not sure if that is causing the issue.

 

Thanks,

Nisha

SanjivMeher
Kilo Patron
Kilo Patron

You need to pass the sysid of the catalog in the query, because it is a list field.

taskGR.addQuery('sysapproval.cat_item.sc_catalog','catalog sysid');


Please mark this response as correct or helpful if it assisted you with your question.