locked
OrganizationServiceProxy - FetchXML RRS feed

  • Question

  • Hi,

    I have an OrganizationServiceProxy object which seems to be retrieving/creating records fine in a specific environment (IFD), however my application makes heavy use of FetchXML queries which return string as an output.

    Any idea how I can execute a straight forward fetch query which returns data in string format?

    Thanks.

    Thursday, November 22, 2012 8:58 AM

Answers

  • Found answer (I believe) just after I posted:


                IOrganizationService _service;
                _service = (IOrganizationService)_orgServiceProxy;
                ExecuteFetchRequest efr = new ExecuteFetchRequest();
                efr.FetchXml = "fetchxmlstring"
                ExecuteFetchResponse response = (ExecuteFetchResponse)_service.Execute(efr);
                return response.FetchXmlResult;

    Thanks.

    Thursday, November 22, 2012 9:04 AM

All replies

  • Found answer (I believe) just after I posted:


                IOrganizationService _service;
                _service = (IOrganizationService)_orgServiceProxy;
                ExecuteFetchRequest efr = new ExecuteFetchRequest();
                efr.FetchXml = "fetchxmlstring"
                ExecuteFetchResponse response = (ExecuteFetchResponse)_service.Execute(efr);
                return response.FetchXmlResult;

    Thanks.

    Thursday, November 22, 2012 9:04 AM
  • ExecuteFetch is the current way to do this. However, be aware that this is marked as deprecated in the SDK documentation, so support for it may be removed at some time in the future

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Thursday, November 22, 2012 9:37 AM
    Moderator
  • I think you should be using the "FetchExpression" & the "RetrieveMultiple" to perform the task for you. The FetchExpression.Query is of type string and will allow you to provide the FetchXML as the parameter. You will however get the  "EntityCollection" object as the response and NOT a string as you want.

    Regards.

    Thursday, November 22, 2012 10:08 AM