Any other ideas out there or corrections that might make this work??



Help is much appreciated!


Hi Alex,


You have mentioned in the requirement that u_supplies variable is referenced to "u_supply_list " table.So according to the scenario you have mentioned I have created a catalog item with same variable name and same table in Demo instance.It's working fine.Please follow below steps.



1.Create a advanced reference qualifier in the u_supplies variable.



find_real_file.png



2.Create a script include with name : filterByLocation



find_real_file.png




Please let me know if you face any issue.



Please mark it as Helpful/Correct according to its impact.




Thanks,


Mihir


Pradeep Sharma
ServiceNow Employee

Hi Alex,



You have to define advance reference qualifier on u_suplies and the reference qualifier will be


javascript:new BackfillAssignmentGroup().BackfillAssignmentGroup()



Script will be


Name : BackfillAssignmentGroup


Script :


var BackfillAssignmentGroup = Class.create();


BackfillAssignmentGroup.prototype = {


  initialize: function() {


  },



  BackfillAssignmentGroup:function() {


  var gp = ' ';


  var a = current.u_location.getDisplayValue(); //Here I am assuming u_location is the column name



  //return everything if the location value is empty or location is omaha


  if(!a || a == 'omaha')


  return;



  var gr = new GlideRecord('u_supply_list');


  gr.addQuery('u_omaha',false);


  gr.query();


  while(gr.next()) {


  if (gp.length > 0) {


  gp += (',' + gr.sys_id);


  }


  else {


  gp = gr.sys_id;


  }


  }


  return 'sys_idIN' + gp;


  },


  type: 'BackfillAssignmentGroup'


}




P.S : Here I am assuming you are not defining the reference qualifier on service catalog variables. Also please define the naming conventions as per your req.



Please let me know if you have any questions.


View solution in original post

Thanks, Pradeep! Nailed it again!



Question though, I want to make sure I understand...



var gr = new GlideRecord('u_supply_list');  


gr.addQuery('u_omaha',false);  


gr.query();  


while(gr.next()) {  


if (gp.length > 0) {  


gp += (',' + gr.sys_id);  


}  


else {  


gp = gr.sys_id;  


}  


}  


return 'sys_idIN' + gp;


},  


type: 'BackfillAssignmentGroup'  


}



What do the bold/underlined bits mean?


Hi Alex,



Thanks for the update. Here is my comment.


if (gp.length > 0) {   //build a comma separated string of supplies if there is more than one


gp += (',' + gr.sys_id);


}



return 'sys_idIN' + gp;


// return supplies