- 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-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...