Reference qualifier in glide_list

salu
Mega Guru

Hi,

I want set a reference qualifier in the glide_list.Can some one help what is the issue with this code?It is not going inside the callback function.

filterSKUByPO: function() {
if (current.variables.u_dos_po_number == '') {
return;
}
var po=current.variables.u_dos_po_number.toString();
var list = po;
var array = list.split(",");

for (var i=0; i < array.length; i++)
{

var gr = new GlideRecord('u_po_sku');
gr.addQuery('u_po', array[i]);
gr.query();
gr.query(myCallbackFunctionforenvironments);
}

function myCallbackFunctionforenvironments(gr){

var sku_po = [];
while (gr.next()) {
sku_po.push(gr.sys_id.toString());
}
return 'sys_idIN' + sku_po.join(',');
}
}
 

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Saranya,



Give this a try... I don't see a need to do an asych GlideRecord query in this case... especially right after you do a synchronous query.


Warning: this code is completely untested. Modifications may be necessary.



filterSKUByPO: function() {


  if (current.variables.u_dos_po_number == '') {


      return;


  }


  var po = current.variables.u_dos_po_number.toString();


  var poList = po.split(',');


  var sku_po = [];



  for (var i=0; i < poList.length; i++) {



      var gr = new GlideRecord('u_po_sku');


      gr.addQuery('u_po', poList[i]);


      gr.query();


      while (gr.next()) {


            sku_po.push(gr.getValue('sys_id'));


      }


  }


  return 'sys_idIN' + sku_po.join(',');


}


View solution in original post

6 REPLIES 6

Kalaiarasan Pus
Giga Sage

I don't see the need to do multiple glidecalls in a loop



if (current.variables.u_dos_po_number == '') {  


      return;  


  }  



  var sku_po = [];  


 



  var gr = new GlideRecord('u_po_sku');  


  gr.addQuery('u_po','IN',current.variables.u_dos_po_number.toString());  


  gr.query();  


  while (gr.next()) {  


            sku_po.push(gr.getValue('sys_id'));  


  }  



  return 'sys_idIN' + sku_po.toString();


This is also working great.I have tried it.This get Value didn't used