- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 03:13 AM
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
Can please someone help me here how can I resolve it
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 03:34 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 03:34 AM
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.