Presentation is loading. Please wait.

Presentation is loading. Please wait.

@CRMUG Technical Academy Fetch Xml Were can Fetch Xml be used Basic Fetch Xml and using advanced find to build your own Fetch Query Creating Fetch Xml.

Similar presentations


Presentation on theme: "@CRMUG Technical Academy Fetch Xml Were can Fetch Xml be used Basic Fetch Xml and using advanced find to build your own Fetch Query Creating Fetch Xml."— Presentation transcript:

1 @CRMUG Technical Academy Fetch Xml Were can Fetch Xml be used Basic Fetch Xml and using advanced find to build your own Fetch Query Creating Fetch Xml that containing outer joins Creating Fetch Xml Queries that contain aggregates How to generate advanced CRM views using Fetch Xml Reference Materials

2 @CRMUG Were can Fetch Xml be used  Using the CRM SDK using OrganizationService.RetrieveMultiple request  SSRS reports authored with Report Authoring Extension  Creating advanced views you are unable to create using the GUI advanced find interface  JavaScript using the SOAP protocol and an OrganizationService.RetrieveMultiple request – Usually Developers will user the ODATA Rest Endpoint to retrieve multiple with JS because of its ease of use

3 @CRMUG C# Retrieve Multiple Example string FetchXml = string.Format(@" ", ConfigurationManager.AppSettings["FromEmailAddress"]); EntityCollection ec = service.RetrieveMultiple(new FetchExpression(FetchXml));

4 @CRMUG C# Fetch Xml Warnings  For larger data (larger than 5000) sets when using Fetch Xml within CRM you will have to paginate your retrieval of the records.  Example Example  The example provided just outputs the results onto a console screen, when I develop items I will with place them into a List or process 5000 records at a time depending on the requirements.

5 @CRMUG Report Authoring Extension  Small application that must be installed on a computer  CRM 2015 Report Authoring Extension CRM 2015 Report Authoring Extension – Visual Studio 2012 or 2010 with SQL Server Data Tools required.  CRM 2013 Report Authoring Extension CRM 2013 Report Authoring Extension – BIDS and Visual Studio 2008 SP 1 required or Visual Studio 2010 with SQL Server Data Tools  CRM 2011 Report Authoring Extension CRM 2011 Report Authoring Extension – BIDS and Visual Studio 2008 SP 1 required or Visual Studio 2010 with SQL Server Data Tools

6 @CRMUG Using Advanced Find to build Fetch Xml  Demonstration  https://clecrmug.crm.dynamics.com https://clecrmug.crm.dynamics.com – crmadmin@clecrmug.onmicrosoft.com

7 @CRMUG Fetch Xml Basics 1 37 6

8 @CRMUG SQL Equivalent select contact.contactid, contact.fullname, contact.emailaddress1, contact.telephone1, account.industrycode, account.revenue, account.name from filteredcontact contact inner join filteredaccount account on account.accountid=contact.parentcustomerid where contact.address1_stateorprovince='OH' and contact.ownerid=@UserGuid and account.industrycode in (1,37,6) order by contact.fullname asc

9 @CRMUG Breaking Down the Basics  Header and Xml Definition   This line is static and should be used in each of your fetch statements.

10 @CRMUG Breaking Down the Basics  Primary Entity   Defines the entity that will be the frame of reference for the remainder of the report.  If you are using this for SSRS reporting and want to use the Pre Filtering functionality this can be done with XML formatted like:  SQL equivalent of from

11 @CRMUG Breaking Down the Basics  Attribute selection –  The attribute name must match the schema name from your Dynamics CRM environment.  SQL equivalent of select  Available attributes of the attribute tag – alias – aggregate – dategrouping(only for date fields) – groupby

12 @CRMUG Breaking Down the Basics  Filtering –  SQL Equivalent of where  Common operators – eq is the equal requires a value – eq-userid is current user no associated value – in is for Pick lists and Lookups ONLY and have tags for each value 1 37 6 – next-x-days requires an integer value – null is the does not contain data this has no associated value – not-null is the contains data this has no associated value

13 @CRMUG Breaking Down the Basics  Sorting –  SQL equivalent of Order By  This line MUST be placed under an entity tag and can never be placed under a linked entity tag – This means you are still bound by the limitation that you can only sort by fields that exist with the primary entity just like views in CRM.  Descending attribute can be true or false

14 @CRMUG Breaking Down the Basics  Link Entity –  SQL equivalent of join  Can contain an additional attribute of link- type to define if this is an inner or outer join. – More on this later

15 @CRMUG Creating Fetch Xml that containing outer joins  The above query is a list of all leads that do not have a task regarding them.  Things to note is the filter is outside of the link-entity and uses an aliased entity name to look for the null reference.  Similar methodologies can be used to generate views with outer joins that you do not want to have an inner join.

16 @CRMUG SQL Equivalent select lead.fullname from filteredleads lead left outer join filteredtasks task on lead.LeadId=task.RegardingObjectId where task.RegardingObjectId is null

17 @CRMUG Creating Fetch Xml Queries that contain aggregates  Why user aggregates instead of retrieving the full data set and using grouping in SSRS – Fetch Xml data sets can be very large and if you are pulling the entire detail for larger data sets the execution time can be quite long for users.  There is a CRM parameter called AggregateQueryRecordLimit which is set to 50,000 records. This means that no single aggregate can contain more that 50,000 distinct recrods. For CRM on premise this can be altered using C# or PowerShell note: this change is at the server level and NOT at the organization level. CRM online this value cannot be changed.

18 @CRMUG Creating Fetch Xml Queries that contain aggregates  Notice the use of the group by to get groupings by year or to include which level you want your aggregates.  Notice how the order uses the alias instead of the attribute that we used previously

19 @CRMUG Creating Fetch Xml Queries that contain aggregates  Available aggregation types – sum – avg – min – max – count(*) – count(attribute name)

20 @CRMUG Creating Views in CRM with an Outer Join  Demonstration  https://clecrmug.crm.dynamics.com https://clecrmug.crm.dynamics.com – crmadmin@clecrmug.onmicrosoft.com

21 @CRMUG Reference Materials  Fetch Xml schema Fetch Xml schema  Fetch Xml based Reports: Bits & Pieces Fetch Xml based Reports: Bits & Pieces  Microsoft Dynamics CRM 2011 – Develop Fetch Xml Based SSRS Reports in Visual Studio 2008 Microsoft Dynamics CRM 2011 – Develop Fetch Xml Based SSRS Reports in Visual Studio 2008  MSDN Building queries with Fetch Xml MSDN Building queries with Fetch Xml

22 @CRMUG


Download ppt "@CRMUG Technical Academy Fetch Xml Were can Fetch Xml be used Basic Fetch Xml and using advanced find to build your own Fetch Query Creating Fetch Xml."

Similar presentations


Ads by Google