locked
Can a single Fetch have multiple queries? RRS feed

  • Question

  • Hi friends,

    I am trying to use fetch on onload of a form so I have to use string like this and I have been successful in fetching a single query but I have to send multiple queries relating to different entities to calculate some total and I didn't want to POST a new XML string again for request as this would make the code double in size for each new query. I was wondering if I could POST the fetch queries together and retrieve and decode the information all together. I am using

     

     var results = oXmlDoc.getElementsByTagName('result');
    to get the result values and to capture the result:-

     

    var resultXml = xHReq.responseXML;

    //Building the FETCH query

    var xml = "<?xml version='1.0' encoding='utf-8'?>"+ "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+ " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+ " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+ authenticationHeader+ "<soap:Body>"+ "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+ "<fetchXml>&lt;fetch mapping='logical'&gt;"+"&lt;entity name='new_

     

    Thursday, September 9, 2010 1:16 PM

Answers

  • I don't know if I understant your question clearly or not , but you can't send multiple query in one Fetch request, but you can retrieve data from related entities using Fetch.
    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 9, 2010 1:23 PM
    Moderator

All replies

  • I don't know if I understant your question clearly or not , but you can't send multiple query in one Fetch request, but you can retrieve data from related entities using Fetch.
    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 9, 2010 1:23 PM
    Moderator
  • Hi Mahender!

    I am trying to read various attributes of different entities related to an the open form ObjectId (which you had previously hinted me).

    Then I will use some mathematical operators on them and display the result on the form. For this I am using the above code which using SOAP to send the request. In this how could I send multiple fetch queries.

    Example:

    myEntity is related to Restaurent which has attribute number_of_staff;

    myEntity is related to Caterers which has attribute class of restaurant;

    I want to retrieve both these attributes in one xml = "<?xml......>

    How could I do this cause Fetch gives some more root elements exception?

    YS,

     

    Sebastian

     

     

    Thursday, September 9, 2010 1:30 PM
  • yes, you can do that you can fetch attribute from multiple entities using Fetch,Donload Fetchxml Builder, which will help you to write your fetch
    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 9, 2010 1:51 PM
    Moderator
  • Yeah this program is very good. I have this program. It helps me build a single Fetch query with various attribute but ONLY on a single entity . How do I query multiple entities?

    Thursday, September 9, 2010 1:54 PM
  • I think I am getting it. Is it using multiple link elements?
    Thursday, September 9, 2010 1:57 PM
  • yes you need to use link to relate entities
    Mahain : http://mahenderpal.wordpress.com
    Thursday, September 9, 2010 2:02 PM
    Moderator