How to relationship between sc_req_item table and alm_asset table to get the 'requested_for' user's 'assigned_to' assets

Anna Gausel
Giga Expert

Hi There,

I have a requirement to include a related list on our requested items that displays the assets assigned to the requested_for user. We have a similar relationship already created on our incident table and it works fine; however when recreating it on our requested item table it shows all assets and not the ones assigned to that specific user.

Here is how I have set up the relationship

Name: Caller Assets

Applies to Table:  Requested Item (sc_req_item)

Queries from table:  Asset (alm_asset)

Query with script:

(function refineQuery(current, parent) {

	current.addQuery('assigned_to', parent.requested_for);
	
})(current, parent);

I used a similar query as our incident table relationship, but changed it to parent.requested_for rather than parent.caller_id to represent the 'requested for' person in the RITM rather than 'caller' on an incident.

Any idea why it is not working?

Many thanks,

Anna

 

1 ACCEPTED SOLUTION

Kamal17
Kilo Sage

Hi Anna,

Try modifying your query as shown below, it should fix your issue.

(function refineQuery(current, parent) {

	current.addQuery('assigned_to',parent.request.requested_for);

})(current, parent);

Mark Correct if this solves your issue. Hit Like/Helpful based on the impact.

Regards,

Udhay

View solution in original post

4 REPLIES 4

Kamal17
Kilo Sage

Hi Anna,

Try modifying your query as shown below, it should fix your issue.

(function refineQuery(current, parent) {

	current.addQuery('assigned_to',parent.request.requested_for);

})(current, parent);

Mark Correct if this solves your issue. Hit Like/Helpful based on the impact.

Regards,

Udhay

Thanks Udhay, this has worked perfectly

HarshTimes
Tera Guru

Hi Anna

OOB requested_for field is available on the sc_request table not on the sc_req_item table . This is the reason why it is not working. Please check if there is any field on the request item table for requested for field.

 

 

Regards,

Harsh

 

Thanks Harsh, I've got it working using Udhay's recommended change.