Need help in auto populating assets assigned to user in catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 03:04 AM
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:
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 03:10 AM
What field (field type) are you trying to populate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 03:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 03:28 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 03:35 AM
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