MS CRM 2011- Fetch method.
-
Wednesday, April 18, 2012 2:47 PM
Hi,
In CRM 4.0 we had a Fetch() method that returned the result of a fetchxml query as xml formatted string. Is this method depricated in CRM 2011? I know that i could serialize a object or build the xml myself, but im looking for the same method that gives the same result as the "old fetch" to simplify an upgrade from 4.0 to 2011.
Update:I can still use the FetchXmlResult property on the ExecuteFetchResponse object. But this is marked as depricated. :(
Is there any alternative that will give me the same result?
Thanks,
Srikanth Reddy
All Replies
-
Wednesday, April 18, 2012 3:18 PM
You can use FetchXML as a Query for RetrieveMultiple requests.
-
Thursday, April 26, 2012 2:57 PM
RetrieveMultipleRequest req = new RetrieveMultipleRequest(); FetchExpression fetch = new FetchExpression(fetchQuery); req.Query = fetch; RetrieveMultipleResponse resp = (RetrieveMultipleResponse)service.OrgServiceProxy.Execute(req);
-
Thursday, April 26, 2012 6:58 PM
//The fetch xml query we want to execute string fetchquery = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='account'>" + "<attribute name='name' /> " + "<attribute name='address1_city' /> " + "<attribute name='primarycontactid' /> " + "<attribute name='telephone1' /> " + "<attribute name='accountid' /> " + "<order attribute='name' descending='false' /> " + "<filter type='and'>" + "<condition attribute='statecode' operator='eq' value='0' /> " + "</filter>" + "<link-entity name='contact' from='contactid' to='primarycontactid' visible='false' link-type='outer' alias='accountprimarycontactidcontactcontactid'>" + "<attribute name='emailaddress1' /> " + "</link-entity>" + "</entity>" + "</fetch>"; RetrieveMultipleRequest req = new RetrieveMultipleRequest(); FetchExpression fetch = new FetchExpression(fetchquery); req.Query = fetch; RetrieveMultipleResponse resp = (RetrieveMultipleResponse)service.Execute(req);
Please check one of my Favorite MVP blog
http://mileyja.blogspot.com/2011/06/use-fetchxml-queries-in-jscript-and-net.htmlI hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
Mubasher Sharif
Check out my about.me profile!
http://mubashersharif.blogspot.com
Linked-In Profile
Follow me on Twitter! -
Monday, September 17, 2012 1:31 PM
Hi,
We are also facing the same issue. We are accesing the dcrm online from java. Earlier we were using the fetch method to retrieve data. But with DCRM online, how can I get the result in xml formatted string as earlier.
Here is the sample output that we got in dcrm4 when we call fetch() method.
<resultset morerecords="0" paging-cookie="<cookie page="1"><contactid last="{F7EA50D7-4208-E111-BAB6-005056AF16B3}" first="{F7EA50D7-4208-E111-BAB6-005056AF16B3}" /></cookie>"><result><customersizecode name="Default Value" formattedvalue="1">1</customersizecode><owningbusinessunit>{262A3BE5-72B9-DE11-810F-000C29286BC8}</owningbusinessunit></result></resultset>
Now we are using OrganizationService and not able to get the output xml directly. We have to loop thru attributecollection and formattedvaluecollection and build the xml. Is there any way by which we can get this xml directly(as it was earlier) instead of building it manually.
Thank you.
Regards
- Kiran