have to populate the serial number of the asset associated to the user record

lakng
Tera Contributor

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.

find_real_file.pngfind_real_file.png

in this variable, the serial number has to populate 

find_real_file.png

1 ACCEPTED SOLUTION

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

View solution in original post

15 REPLIES 15

lakng
Tera Contributor

have changed, still not working Asif

did it worked you side? this scenario

Yes, the code is working fine. I tested on change of caller id in incident table and set the assets in the short_description field and its working fine.

1. change that parameter which i mentioned above

2. Ensure the onchange client script field is selected correctly

3. Check if the field name is correct "the_serial_registered_for_the_user_is"

Lastly add logs and check 

Mark the comment as a correct answer and helpful once worked.

lakng
Tera Contributor

i have modified my client script to run onLoad as well,

but there is some problem the field is showing details populated wrongly.

find_real_file.pngtthis is client script modified,

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {

// 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);

});
return;
}
}

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

Kindly mark the comment as a correct answer and also helpful  if this answers your question.