Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harsh
Helper I
Helper I

Connecting to CRM saved views

Hello,

 

I can connect to CRM using Dynamics 365 however I can see only tables listed no saved views, is there a way to connect to views.

If not then could you please give me an idea to do this alternatively using some othere tools like azure, C# and so on.

 

Right not we call CRM views and export csv files using powershell command and now we need to make this process automated (I guess for direct connection no schedule refresh required correct  me if I'm wrong) so please give me an idea to do this effortlesly.

 

Note : I want to call views and don't want to play with tables by manipulating since it won't fit our project.

10 REPLIES 10
v-ljerr-msft
Employee
Employee

Hi @harsh,

 

We can't connect directly to saved views in CRM currently as KHorseman mentioned above. Please vote the similar idea here.Smiley Happy

 

In addition, here is similar thread in which mentioned using OData and Dynamics CRM OData Query Designer to connect to CRM saved views. Please go and check if it could help.

 

Regards

Hi @v-ljerr-msft\ @KHorseman,

 

Well Powershell can do this using "Microsoft.Xrm.Data.PowerShell" library, there should have been some funtionality in Power bi.

 

Right now our current architecture is like we are using powershell to call crm saved user views then data is exported to our local machine in the form of .csv file then we upload data from csv file to Power bi so all this is a manual process.

We need to make this automated like there should be some way where we don't have to export csv file and upload in Power Bi and there should not be manual refresh, all should be automated.

 

Please suggest some best and effective solution to achieve this( like related to Azure,Powershell, C#, Sharepoint and so on)

KHorseman
Community Champion
Community Champion

@harsh as I suggested earlier, you can query that UserQuery table and get the FetchXML code for those views. Then you can translate that into SQL and use those SQL statements as a starting point for queries in Power BI. Setting them up for the first time is a manual process but after that Power BI will simply refresh its data to pull that view.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Sorry @KHorseman, I don't know how to do this, could you please help me by showing steps/snapshots ?

 

Right now one thing I tried while making connection, I called the tables and its columns, however this is TEDIUS TASK.

 

https://cne*********.com/XRMServices/2011/OrganizationData.svc/EE_programenrollmentSet?$filter=statecode/Value eq 0&$select=EE_EngagementRating,EE_CustomerEvidence,EE_NomindatedById,EE_AccountId

 

This will bring only that data which I want.

KHorseman
Community Champion
Community Champion

Once you connect, you can just make queries in Power BI that replicate your list views. Pick the table you want, then go through all the normal steps of choosing columns to keep, filtering the results, etc. You'll be recreating those list views from scratch. Annoying but not too difficult. The FetchXML method I suggested is no less tedious, but it is an alternative.

 

If you want to get the existing list view queries from CRM and translate them, you need to first connect and query the UserQuery table in the query editor. Look for the row with the name of the view you want to replicate and find the FetchXML column. Take the text from that cell and run it through a FetchXML to SQL translator. This one is pretty good. Take the resulting SQL and go back to the query editor in Power BI. Add a new blank query and open the Advanced Editor. In that window write a query that looks like this:

 

let
    Source = Sql.Database(
		"nameOfSQLServerGoesHere",
		"nameOfDatabaseGoesHere",
		[Query="stuff from the FetchXML to SQL converter goes here"]
	)
in
	Source

That will approximately give you the list view as a Power BI query. There are some odd quirks to FetchXML though. Whichever column or columns in CRM were chosen as the sort order for the list view may be left out of the SELECT list in the resulting SQL. They end up in a GROUP BY argument instead, so you might need to add those columns to the SELECT yourself.

 

Usually it's going to be easier to just build a new query in the query editor the same way as connecting to any other source. If you're not familiar with that method you need to check out some basic tutorials on using Power Query. Sometimes translating the FetchXML can be a useful alternative, for instance if you have a really complicated list view and you're not familiar with where it's getting everything.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




let
    Source = Sql.Database(
		"nameOfSQLServerGoesHere",
		"nameOfDatabaseGoesHere",
		[Query="stuff from the FetchXML to SQL converter goes here"]
	)
in
	Source

Not sure why you have specified sql database instead of crm, one thing which I find it as a flaw is while connecting to crm and while loading data, its too slow it takes more than 30 min to load data while from csv it takes less than a min.

 

Well I 'm thinking to have a powershell script which will be on Azure and that would be scheduled which will pull data from CRM and export in csv format somewhere in azure, same will be uploaded in Powerbi from Azure and then data gets automatically refreshed from Azure, Is this feasible please share your thoughts and if you have any smarter way to do this, let me know

KHorseman
Community Champion
Community Champion

I've specified SQL because that's your only other choice aside from the standard method of connecting to CRM and creating your own queries. I don't actually recommend doing this but it's the closest thing that exists to your request of connecting to the existing list views. If you really want to use the existing list view queries without just creating your own Power BI queries, the only way is to go through the SQL server backend and use a SQL translation of the FetchXML code behind those list views.

 

But really, you should just connect to your CRM source and create a query using the query editor's normal methods. Because obviously this sql translation method takes just as much work.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @KHorseman,

 

Well I dropping the idea to connect directly to CRM, because it takes a lot of time to connect and its tedius as well.

 

Well as said I 'm thinking to have a powershell script which will be on Azure and that would be scheduled which will pull data from CRM and export in csv format somewhere in azure, same will be uploaded in Powerbi from Azure and then data gets automatically refreshed from Azure, Is this feasible please share your thoughts please let me know

KHorseman
Community Champion
Community Champion

If you're at the point of pulling the data from CRM to an intermediate data source, I'd say you should start considering building a data warehouse. That's my long-term plan for handling our CRM data. Loading to a temporary csv is fine but at that point you're already halfway to a data warehouse and you might as well think about taking it the rest of the way, especially if you're already using Azure.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




KHorseman
Community Champion
Community Champion

You can't connect directly to views in CRM because they are not saved as database views. They are stored as FetchXML queries in a text column in a table in the SQL backend of CRM. The table is called UserQuery I think. It won't help you to know that, because CRM doesn't parse FetchXML, but maybe it's nice to know as an interesting bit of trivia.

 

Best you can do is either use Power BI to find those FetchXML queries and then go copy and paste them into a converter that translates them to SQL, then enter those SQL queries in Power BI. There is no effortless way to connect to them.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.