Need help in auto populating assets assigned to user in catalog item

Hritik
Tera Expert

Hi Community,

 

I want to auto populate the Assets that are assigned to user in Offboarding catalog form.

When the requestor select the user name who is being offboarded his assets must also be auto populated in other variable.

 

I tried via On Change client script but it seems I'm failing at some point.

The assets linked to user can be multiple, so I'm confused how do I write fields for it.

 

For ex: Below is the My Assets report that shows assets assigned in alm_asset table:

Hritik_0-1706785288343.png

 

As you can see there can be multiple assets assigned to user. My requirement is to populate this data on the Offboarding form somehow.

 

The client script I tried:

var assetGR = new GlideRecord('alm_asset');
    assetGR.addQuery('assign_to', userId);
    assetGR.query();

    // Clear existing values in asset fields
    g_form.setValue('variables.asset', ' '); 

    // Loop through the assets and populate catalog item fields
    while (assetGR.next()) {
        g_form.setValue('variables.asset', assetGR.getValue('display_name')); 
      
    }

 

Please suggest me a way how can I bring this data on the catalog form.

 

 

Thanks in Advance,

Hritik

12 REPLIES 12

Sonam_Tiwari
Kilo Sage

add -> ;no_filter in variable attributes

 

Available Bucket List to Selected Bucked List - I saw this coming..

 

For this - https://servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/

Consider indicating the response as helpful and marking it as correct if it meets your needs.

Hi Sonam,

with the existing reference qualifier the no_filter attribute isn't working. If I only added no_filter in varaible attribute then it works but not with exisitng

ref_qual_elements=employee_to_offboard;no_filter

 

I tried many combinations. 

Could you suggest what is it that I'm doing wrong ?

Please ignore previous mesg. I was using wrong syntax to concatenate attributes. 

I used comma which is working