The CreatorCon Call for Content is officially open! Get started here.

Querying Related Tables sc_req_item and sc_cat_item

kailashthiyagar
Kilo Guru

My requirement is to pass in the "Requested Item number" and "requested item name" and check whether any records exist...

Noticed that name field is present in different table sc_cat_item... I m passing in the Requested item number and name from my client script.. This is the below code i m using...

but do we have an option to do dot walking and do this validation.. i tried it but it doesnt work... could any suggest how we can do it in simplied way?

var reqDetails = new GlideRecord('sc_req_item');

  //var catItem = reqDetails.addJoinQuery('sc_cat_item');

  reqDetails.addQuery('number',g_form.getValue('request_number_2'));

  //catItem.addCondition('name', 'Hardware Exception Appeal');

  reqDetails.query();

  //create and return the array of environments

  while(reqDetails.next()){

  var catItemData=new GlideRecord('sc_cat_item');

  catItemData.addQuery('sys_id',reqDetails.cat_item);

  catItemData.query();

  while(catItemData.next()){

  //do the logic over here

  }

}

25 REPLIES 25

It is hard to tell without actually having your hands on. If it is possible to give access, I can look into it.