Change values with Lookup Multiple Choice for catalog item

tschenke
Giga Contributor

We are implementing a hardware refresh program and I am trying to create a catalog item using the order guides that we would send the users to to select their new hardware.   One of the variables I have set up is a lookup multiple choice that uses the requested_for variable to pull back all of their assigned assets.   This uses a script include I was able to find on this site.   The requested_for is defaulted to the logged in user and when the form loads, it works like a charm and pulls back the list of assets.   However, when I change requested_for on the form, the multiple choice options do not refresh.   I'm assuming that this needs to be done with a Catalog Client Script with an onChange on requested_for but I can not get the script to actually make the change.  

1 ACCEPTED SOLUTION

tschenke
Giga Contributor

I found a solution on an old thread and tried it and it works great.   I had to add ref_qual_elements=requested_for in the Variable Attrributes and everything works as I need.  


View solution in original post

4 REPLIES 4

march
Kilo Guru

Hi Tony,



For people to help you, you would have to share your scripts so someone can check it and identify necessary corrections.



BR


Marcus


tschenke
Giga Contributor

Thanks for the reply.  



I have a script include called getAssignedTo.   From the variable in my form called old_computer, I used a lookup multiple choice option and as the reference qualifier I call the getAssignedTo().assigned().


find_real_file.png


In the form there is also a requested_for variable that defaults to the current logged in user, so when the form orginally loads, everything works fine as the script below runs to populate the choices for the old_computer variable.   However when the requested_for changes, the choices for the old_computer do not refersh.   I was thinking that I needed to include a Catalog UI policy (could be completely off base) that would run onChange when the requested_for variable changes. This is where I get stuck.



getAssignedTo:


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;


  },


  }


tschenke
Giga Contributor

I found a solution on an old thread and tried it and it works great.   I had to add ref_qual_elements=requested_for in the Variable Attrributes and everything works as I need.  


I know this was an old post but as a recent new user, this has helped me no end. Thanks.