Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

show asset details according requested for (reference qualifier)

lucky24
Tera Contributor

Hi Team, 

I have two variable requested for(reference filed  referring to sys_user ) and asset (reference filed  referring to sys_user).

My requirement is when I click on reference field it should only show those asset which is assignee to requested for user and model is yubikey.

I have created script include and 

My asset variable and script include both in scoped application

 

Script include-

var yedassetdetails = Class.create();
yedassetdetails.prototype = {
    initialize: function() {},

    yedAsset: function(a) {
     gs.info("Test1234 " + a);
        var arryVal = [];
        var gr = new GlideRecord('alm_asset');
        gr.addQuery('assigned_to', a);
        gr.addQuery("model", "41ce0cb2974abd584649b0d3f153af8b");
        gr.query();
        while (gr.next()) {
            arryVal.push(gr.display_name.toString());

        }

        return 'sys_idIN' + arryVal;

    },
    type: 'yedassetdetails'
};

 

Reference qualifier

I tried with different way 

javascript: new yedassetdetails().yedAsset(current.variables.requested_for);
javascript: new x_gnvi2_yubico_ent.yedassetdetails.yedassetdetails().yedAsset(current.variables.requested_for);

 Accessible from -All application scope

 

I am getting error in logs

lucky24_0-1698747197589.png

Can please someone help me here how can I resolve it

 

 

 

 

1 ACCEPTED SOLUTION

Harsh_Deep
Giga Sage
Giga Sage

Hello @lucky24 

 

Please use this script -

var yedassetdetails = Class.create();
yedassetdetails.prototype = {
    initialize: function() {},

    yedAsset: function(a) {
     gs.info("Test1234 " + a);
        var arryVal = [];
        var gr = new GlideRecord('alm_asset');
        gr.addQuery('assigned_to', a);
        gr.addQuery("model", "41ce0cb2974abd584649b0d3f153af8b");
        gr.query();
        while (gr.next()) {
            arryVal.push(gr.sys_id.toString());

        }
        return 'sys_idIN' + arryVal;
    },
    type: 'yedassetdetails'
};

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

View solution in original post

1 REPLY 1

Harsh_Deep
Giga Sage
Giga Sage

Hello @lucky24 

 

Please use this script -

var yedassetdetails = Class.create();
yedassetdetails.prototype = {
    initialize: function() {},

    yedAsset: function(a) {
     gs.info("Test1234 " + a);
        var arryVal = [];
        var gr = new GlideRecord('alm_asset');
        gr.addQuery('assigned_to', a);
        gr.addQuery("model", "41ce0cb2974abd584649b0d3f153af8b");
        gr.query();
        while (gr.next()) {
            arryVal.push(gr.sys_id.toString());

        }
        return 'sys_idIN' + arryVal;
    },
    type: 'yedassetdetails'
};

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.