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

Hritik
Tera Expert

I was able to add Reference Qualifier to field in catalog form that atleast narrowed down assets assigned to User.

For ex: When I selected David Anderson in 'Employee to Offboard' field, 

Hritik_0-1706786936982.png

The assets shown in the reference list were only those assigned to David Anderson.

Hritik_1-1706786998760.png

 

But I need this data to be populated on the form somehow. Not sure what field type I can use here.

Sonam_Tiwari
Kilo Sage

Share it here once

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

This is the reference qualifier being used:

javascript: 'assigned_to=' + current.variables.employee_to_offboard;

 

It works for field type Reference but not for List collector

Sonam_Tiwari
Kilo Sage

In ' variable attributes ' of list collector put ref_qual_elements=employee_to_offboard

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

Hi Sonam,

 

Thanks, that was helpful.

Altough, can you please let me know if there's any way to hide filter conditions for List collector:

Hritik_0-1706796385144.png

 

I don't want to show the filter conditions here or is there a way I can populate the values in Available Bucket List to Selected Bucked List