Catalog items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
20 hours ago
When I want to return a hardware asset or deploy an asset to a different location within the same building/premise
Then I should have a catalog item to submit the request and the catalog item should allow me to provide the following information for the request:
- Hardware asset or Consumable
- Asset Action
- Return stockroom
- Re-deployment location
Where
- Only the hardware asset(s) or consumable(s) assigned to the requester can be selected
- Choices for Asset Action are: Return, Re-deployment
- 'Return stockroom' is only applicable when 'Return' is selected for 'Asset Action'
- For 'Return stockroom', only the stockroom(s) linked to the hardware asset can be selected
- 'Re-deployment location' is only applicable when 'Re-deployment' is selected for 'Asset Action'
- For 'Re-deployment location', only the location(s) within the same building of the selected hardware asset can be selected
I am stucked at
- For 'Return stockroom', only the stockroom(s) linked to the hardware asset can be selected.
- For 'Re-deployment location', only the location(s) within the same building of the selected hardware asset can be selected
please provide solution for it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
Hi @devanshsing
This requirement cannot be achieved using only static reference qualifiers, because both Return stockroom and Re-deployment location depend on the selected asset. The correct approach is to use Advanced Reference Qualifiers with a client-callable Script Include.
Steps
1. Asset selection (only requester’s assets)
For the Hardware Asset / Consumable catalog variable (Reference → alm_asset):
Reference qualifier:
assigned_to=javascript:gs.getUserID()
This ensures the requester can select only assets assigned to them.
2. Create a client-callable Script Include
var AssetReturnRedeploy= Class.create();
AssetReturnRedeploy.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getLinkedStockrooms: function () {
var assetId = this.getParameter('sysparm_asset_id');
if (!assetId)
return '';
var assetGR = new GlideRecord('alm_asset');
if (assetGR.get(assetId) && assetGR.stockroom) {
return assetGR.stockroom.toString();
}
return '';
},
getSameBuildingLocations: function () {
var assetId = this.getParameter('sysparm_asset_id');
var result = [];
if (!assetId)
return '';
var assetGR = new GlideRecord('alm_asset');
if (assetGR.get(assetId) && assetGR.location) {
var locGR = new GlideRecord('cmn_location');
if (locGR.get(assetGR.location) && locGR.building) {
var sameBuildingLoc = new GlideRecord('cmn_location');
sameBuildingLoc.addQuery('building', locGR.building);
sameBuildingLoc.query();
while (sameBuildingLoc.next()) {
result.push(sameBuildingLoc.sys_id.toString());
}
}
}
return result.join(',');
}
});3. Return Stockroom variable qualifier
For Return stockroom (Reference - alm_stockroom)
Use Advanced reference qualifier:
javascript:'sys_idIN' + new AssetReturnRedeploy()
.getLinkedStockrooms(g_form.getValue('hardware_asset'))
Result
Only the stockroom linked to the selected asset is displayed.
4. Re-deployment Location variable qualifier
For Re-deployment location (Reference - cmn_location)
Use Advanced reference qualifier:
javascript:'sys_idIN' + new AssetReturnRedeploy()
.getSameBuildingLocations(g_form.getValue('hardware_asset'))
Result
Only locations within the same building as the selected asset are displayed.
5. Show / hide variables based on Asset Action
Catalog Client Script
Type: onChange
Variable: Asset Action
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading)
return;
g_form.setDisplay('return_stockroom', newValue === 'Return');
g_form.setDisplay('redeployment_location', newValue === 'Re-deployment');
}
*************************************************************************************************************
If this response helps, please mark it as Accept as Solution and Helpful.
Doing so helps others in the community and encourages me to keep contributing.
Regards
Vaishali Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
so where are you stuck?
what variable you created? reference etc? reference qualifier help is required?
share some details and screenshots
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
@Ankur Bawiskar I have created variables I have added reference qualifier for asset so asset which is only assigned to me is visbile. I am facing issue to fetch the particular location of the asset which is assigned to me and I want to only fetch those stockrooms which is available on that particular location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
19 hours ago
suppose asset which is assigned to me is apple macbook so I just want to fetch location of this asset. and if location have 2 stockroom then just want to fetch those 2 stockroom I have tried script include and called them in reference qualifier but that not worked.
