How can I reach Embedded Lists from a GlideRecord Query?

paul971
Mega Expert

Hi All -

I have a scripted web service for a static WSDL and need to reach some of the embedded lists on that form. I understand the challenges for this as they are not really related to that form. However, is there anyway possible that I can dot-walk or something?   Would it be best to build my GlideRecord script from the parent table down?

Any insight is appreciated. I'm happy to clarify wherever needed.

oh and, this is on Fuji if that matters. Thanks in advance!

9 REPLIES 9

Masha
Kilo Guru

Embedded list is pretty much the same as a Related List but displayed differently. So if you want to get to the data in that list you will have to query the table that list comes from with the same query used to display it on the form you are talking about.


Ok, so in my WSDL I'll need to make an additional GlideRecord call to the other table(s) for the embedded lists?


masha, Hi



something like this   ..



var test = new GlideRecord("table");


            test.orderBy('field');


            test.query();


while(test.next()) {


          var item = xmldoc.createElement("getRecords");


  // move to inner element


  xmldoc.setCurrent(item);


  xmldoc.createElement('field1', test.sys_id);


  xmldoc.createElement('field2', test.number.getDisplayValue());



var test2 = new GlideRecord("table_2");


            test2.orderBy('whatever');


            test2.query();


while(test.next()) {


          var item = xmldoc.createElement("getRecords");


  // move to inner element


  xmldoc.setCurrent(item);


  xmldoc.createElement('field1', test2.sys_id);


  xmldoc.createElement('field2', test.number.getDisplayValue());


If you want to be able to get the data from both tables in the same call I would suggest you build a Javascript object to hold your data, covert it to XML and returning it. Your GlideRecord call would look something like:



var test = new GlideRecord("table");


            test.orderBy('field');


            test.query();


while(test.next()) {


//get the values you need from the record.


...


        //get embedded list values for this record


        var embedded_list_item = new GlideRecord("embedded_list_table");


                      embedded_list_item.addQuery(<query to get the related records from the embedded list table>);


                      embedded_list_item.query();


                      while(embedded_list_item.next()) {


                            //get the values you need from the embedded list records


                            ...


                      }


}