- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2016 01:35 AM
Hi ,
I have a catalog item where we have 2 variables
requested for (reference field of user table)
serial number (reference field of asset table)
Based on the selection of 'requested for', i need to get all the assets assigned to him/her in the lookup field of 'serial number'
Please help me out.
Thanks in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 06:07 AM
Script Include:
Name: getAssignedTo
Client Callable: False
Code:
var getAssignedTo = Class.create();
getAssignedTo.prototype = {
initialize: function() {
},
assigned:function() {
var gp = ' ';
var a = current.variables.requested_for;
if(!a)
return;
var grp = new GlideRecord('alm_hardware');
grp.addQuery('assigned_to', a);
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.sys_id);
}
else {
gp = grp.sys_id;
}
}
return 'sys_idIN' + gp;
},
}
Advance reference qualifier: javascript:new getAssignedTo().assigned()
Note: Please provide the correct variable names and table names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 05:53 AM
I would think you could make it even simpiler from what i am seeing.
For your reference qualifier on the asset lookup Try:
javascript: 'assigned_to=' + current.variables.<requested for variable's name>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 05:59 AM
Hi Jacob,
thanks for your reply
It is still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 06:07 AM
Script Include:
Name: getAssignedTo
Client Callable: False
Code:
var getAssignedTo = Class.create();
getAssignedTo.prototype = {
initialize: function() {
},
assigned:function() {
var gp = ' ';
var a = current.variables.requested_for;
if(!a)
return;
var grp = new GlideRecord('alm_hardware');
grp.addQuery('assigned_to', a);
grp.query();
while(grp.next()) {
if (gp.length > 0) {
gp += (',' + grp.sys_id);
}
else {
gp = grp.sys_id;
}
}
return 'sys_idIN' + gp;
},
}
Advance reference qualifier: javascript:new getAssignedTo().assigned()
Note: Please provide the correct variable names and table names.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 08:11 AM
Hi Paul,
Tried your code also.It is still not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2016 08:59 AM
Could you please post what you have written with the screenshot of the configure variables.