- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 07:51 AM
I am using the OOB Asset Loaner catalog item. There is a reference qualifier that is based on the asset function type of loaner, which is this:
I am using the OOB Asset Loaner catalog item. There is a reference qualifier that is based on the asset function type of loaner, which is this: new sn_hamp.HampLoanerUtils().getModelsWithLoanerAssets(current.variables.location)
I have added another type in the asset function field, loaner_international. I also created another function under the HampLoanerUtils() called getModelsWithIntLoanerAssets(). My question is how do I change the reference qualifier based on the asset function selection? Need some help to get it started. Do I use dynamic reference qualifier?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2022 04:12 AM
What you'll want to do is make a copy of the original Script Include, then change the reference qualifier to use your new SI name, and also pass in the asset_function if you want the reference choices to change based on the asset_function. I didn't clarify this, so if what you're looking for is the reference choices to include both loner and loner_international I think you'll just need to change one line in the SI (line 746 mentioned below). Making a copy of the SI ensures that the original script will be updated with future patches and upgrades, so you can re-do your changes in the copy or incorporate the updates if something stops working after an upgrade.
Assuming you want the reference choices to change based on asset_function, add the argument to the getModelsWithLoanerAssets function like you did, but on HampLoanerUtils.addLoanerBaseQuery you'll want to also pass in ' ' as an argument before asset_function as this function is already expecting 3 arguments, and OOB is only sending 2.
So line 8:
HampLoanerUtils.addLoanerBaseQuery(assetsGa, location, '', asset_function);
then that function in line 770 (of your modified version of the SI):
HampLoanerUtils.addLoanerBaseQuery = function(assets, location, model, asset_function) {
var commonBaseQuery = HampLoanerUtils.getLoanerCommonBaseQuery(location, model, asset_function);
continuing down the rabbit hole to line 744 so that we can finally use the new argument on line 746:
HampLoanerUtils.getLoanerCommonBaseQuery = function(location, model, asset_function) {
var assets = new GlideAggregate('alm_asset');
assets.addQuery('asset_function', asset_function);
That gets the LoanerBaseQuery updated, but I see 'loaner' hard-coded in line 35, so you'll have to so the same there and trace back where that function is called to pass the argument...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 10:14 AM
Hi Brian,
You cannot dynamically change the reference qualifier itself, so what you'll want to do is use either the original or your function, and make it also accommodate the asset function. The first part of this will be passing in the asset function field selection
new sn_hamp.HampLoanerUtils().getModelsWithLoanerAssets(current.variables.location, current.variables.asset_function)
or whatever the name of your variable is. Next, modify the Script Include function to accept this parameter as an argument, then filter the results based on this. I'm presuming the 'loner' type is hard-coded in this script somewhere, but I don't have hamp in my environment, so post that Script Include if you need further help getting this to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 12:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 12:35 PM
I would have to see the full Script Include to trace through the other referenced functions (addLonerBaseQuery, addInUseFunctioningAssetsQuery,...). Unfortunately, HAMP is not available to install in my PDI and I don't have access to it in my environment. Did you try to paste the code using the Insert/Edit code icon </>?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2022 12:56 PM