- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 10:58 PM
I am trying to populate a computer name associated with a user using a variable, once the reference field is added with the persons name the next field which is list of assets should populate with computer names of that specific user. Not the logged in user. I assume i am needing a catalog client script? What would the script be??
The variable for logged on behalf of user is: requested_for
and computer name ref: list_of_assets_stolen
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 04:23 AM
If still, it doesn't help you. please refer to the below article for auto-population.
https://community.servicenow.com/community?id=community_article&sys_id=74ccee25dbd0dbc01dcaf3231f9619bd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 11:47 PM
Where is the computer name assigned to the user stored? You have to write an onChange Client Script, which will run on Chnage of the User variable.
You can do a GlideAjax call to a Script Include and pass the user selected, i.e., newValue. In the script Include Glide the table where the computer-to-user mapping is stored and the return the computer Name for the selected user.
If you face challenge scripting it, mention the name of the table for computer-to-user mapping. I can provide you with the script
Regards
Air
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2019 11:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 12:00 AM
Assumption: List of assets stolen refers to cmdb_ci_computer table
Client Script - onChange of requested_for:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var abc = new GlideAjax('ComputerAssigned');
abc.addParam('sysparm_name','getComputer');
abc.addParam('sysparm_usid',newValue);
abc.getXML(Fundo);
}
function Fundo(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('list_of_assets_stolen',answer);
}
Script Include - Client callable checked to true.
var ComputerAssigned = Class.create();
CallerRoles.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getComputer: function(){
var computer = '';
var uid = this.getParameter('sysparm_usid');
var com = new GlideRecord('cmdb_ci_computer');
com.addQuery('assigned_to',uid);
com.query();
if(com.next()){
computer = com.sys_id;
}
return computer;
},
type: 'ComputerAssigned'
});
Regards
Air
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2019 12:11 AM