How to create relationships between sc_task and alm_asset tables using custom relationship

madhusagar
Tera Contributor

Hi Team,

 

I need assistance in creating a custom relationship between the sc_task and alm_asset tables in ServiceNow.

The requirement is as follows:

1. The relationship should display only the assets selected in the item variables of the sc_task record.

2. The related list should dynamically filter and show only the selected assets based on this variable value.

 

I attempted to achieve this using a relationship query, but it is currently not working as expected. Kindly guide me on how to configure the relationship so that the selected asset appears correctly in the related list.

madhusagar_0-1755154596928.png

 

Thanks & Regards,

Madhu. 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@madhusagar 

this will work fine provided your variable is referring to alm_asset table

var ritmRecord = parent.request_item.getRefRecord();

var assetSysId = ritmRecord.variables.variableName; // give your variable name here

current.addQuery('sys_id', assetSysId);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@madhusagar 

this will work fine provided your variable is referring to alm_asset table

var ritmRecord = parent.request_item.getRefRecord();

var assetSysId = ritmRecord.variables.variableName; // give your variable name here

current.addQuery('sys_id', assetSysId);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader