Advanced reference qualifier for variable in record producer

abjaffrey
Giga Guru

Hi all,

 

I have a use case in a record producer form

  • there is a requested for field which references the user table
  • there is an asset details field which references alm_hardware table

My need is that based on requested for, the asset details variable should only display the assets assigned to the selected user. can someone help me with this.

 

Advanced ref qualifier for the variable :

 

javascript: new getGroupMember().assignedAssets(caller_id);

 

SI:

 

    assignedAssets : function(getUser)
    {
        var assets = [];
        var abc = new GlideRecord('alm_hardware');
        abc.addQuery('assigned_to',getUser);
        abc.query();

        while(abc.next()){
            assets.push('asset_tag');
        }
        return assets;
    },

abjaffrey_0-1718780572040.png

 

2 ACCEPTED SOLUTIONS

Sebastian L
Mega Sage
javascript: 'assigned_to='+current.variables.caller_id

Just add this to the reference qualifier of  your asset details


Best regards,
Sebastian Laursen

View solution in original post

hi @Sebastian L 

 

thanks for the response, it worked.

 

View solution in original post

6 REPLIES 6

briannice
Kilo Sage

Hi @abjaffrey 

 

You need to return the encoded query for the reference qualifier and not a list of records.

 

Also check if you are using the correct name of the application scope, and name of the script include. Add the caller id in the reference qualifier by using 'current.variables.caller_id'.

 

Kind regards,

Brian

 

 

// Reference qualifier
javascript: new global.getGroupMember().assignedAssets(current.variables.caller_id);

// Script include
// Application scope -> global
// Name -> getGroupMember
assignedAssets : function(getUser) {
        var abc = new GlideRecord('alm_hardware');
        abc.addQuery('assigned_to',getUser);
        return abc.getEncodedQuery();
},

 

 

 

Hi 

 

thanks for the response but it did'nt work

Akshay03
Kilo Sage

Hello @abjaffrey ,
You cannot return array in reference qualifier. it should be records

 

assets.push(abc.getValue('asset_tag'));

 

if you're trying to it via client script. Use this in you script, other than that it seems fine.

Regards,
Akshay

Hi 

 

thanks for the response, the output dint work