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

What field (field type) are you trying to populate?

 

 

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

Hi Sonam,

 

That is what i'm confused about. There are multiple assets assigned to user in alm_asset table. 

So, I don't know what field type can acheive this requirement to populate multiple records.

 

Right now I kept it as Reference field trying to populate at least one asset as of now

Sonam_Tiwari
Kilo Sage

I would say keep it as a list collector and point it to your table. Once that is done you can build a logic to populate the list collector with the assets that belong to the current user.

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

Hi Sonam,

I tried the same reference qualifier I used for Field (type-ref) for List collector Field. 

But the List is showing all the data in the table. 

I need the data to be narrow down