- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2020 11:34 PM
we have a catalog variable in one item, serial number
in this serial number, serial number of the asset of that user contains has to populate.
here am attaching the user record form, the asset attached to this user record. serial number will be in this asset table (alm_hardware)
so we need to have onchange client script and one script include.
by changing the user in the catalog item, the serial number has to change based on the user.
in this variable, the serial number has to populate
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2020 05:07 AM
add alert(g_form.getValue('user')); and check what is the user.
Then go to alm_hardware.list and there add filter assigned_to and put this user and check the no. of entries it has.
Compare it with the output of SI

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2020 01:14 AM
Hi,
In alm_hardware, you can find the asset. What is the relationship between user and asset? ARe you considering owned_by or assigned_to or managed_by field in alm_hardware table?
Secondly, what if the user has multiple assets, which asset serial number do you want to fill in? What are the fields you have in the catalog item?
Mark the comment as a correct answer and helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2020 01:42 AM
What is the relationship between user and asset?
every user will be having assets with him. so we have see what assets he has been using by looking in to the user record.
ARe you considered owned_by or assigned_to or managed_by field?
assigned_to
all serial number have to display separated with commas
i have one field in the catalog item, which is serial_number. this field has to fill with the serail number associated to that user (submitted_by).
if the submitted by changes, then associated asset serial numbers has to display.
basically its onchange
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2020 02:47 AM
this is my script include which is not working
var userInfoAjax = Class.create();
userInfoAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssets: function(){
var returnString = 'The serial registered for the user is ';
var arr = [];
var UserId = this.getParameter('sysparm_user_name');
var gr = new GlideRecord('alm_hardware');
gr.addQuery('assigned_to',UserId);
gr.query();
while(gr.next()){
arr.push(gr.getValue('serial_number'));
}
returnString = returnString + arr.join(',');
return returnString;
},
type: 'userInfoAjax'
});
and this is the client script:
on change : sub_name
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Call the GA function
var ga = new GlideAjax('userInfoAjax');
ga.addParam('sysparm_name', "getAssets");
ga.addParam('sysparm_user', g_form.getValue('user'));
ga.getXMLAnswer(function(answer){
g_form.setValue('the_serial_registered_for_the_user_is', answer);
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2020 03:08 AM
Hi,
The parameter you are sending is wrong.
In your SI, change this line
var UserId = this.getParameter('sysparm_user_name');
TO
var UserId = this.getParameter('sysparm_user');
Mark the comment as a correct answer and helpful once worked.