Asset Loaner Reference qualifier help

Brian DeBlis
Tera Expert

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

 

1 ACCEPTED SOLUTION

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

 

 

 

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

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.

I am trying to add asset_function to this script include and the reference window is coming up blank. I am assuming I need to add in three locations, which I did in the snippet. I have attached the code snippet, since it will not let me add it into the message for some reason.


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 </>?  

Here is the entire script include. It is more than 30000 characters, so have to attach