Dynamics
CRM 2011 provides us the Charts, with the help of the Charts we can Graphically
represent the Organization data. We can create the System Charts and User
Charts in the CRM. The System Chats can be viewed by the All users of the
Organization and the User Charts can only be view by those whom the Chart
Assigned or Shared.
We can create the following different form of charts:
• Column
• Bar
• Line
• Pie
• Funnel
To create a chart, specify fields to be displayed on the category and series axes. Normally, the category axis displays data from numeric or non-numeric fields. The series axis displays data from numeric fields.
The Chart Designer supports creating only single-series charts. To create multi-series charts or comparison charts, we need to write the code.
Also we can Export and Import the Charts.
Note: We can create and attach charts to only those record types in Microsoft Dynamics CRM that support the new ribbon interface in the Web application. This is because all of the chart controls are only present in the ribbon interface of Microsoft Dynamics CRM.
We can create the charts from the CRM Views or by the Coding.
Create the Charts through CRM Views: You need to create the CRM view on the required Entity and then create the chart on this. As shown in the below screen shot we have create the view of all opportunity and then create the Sales Pipeline Chart for that view. As shown in the below screenshot.
Now open the Opportunity Entity and Create the Chart as shown in the below screenshot.
We can create the following different form of charts:
• Column
• Bar
• Line
• Pie
• Funnel
To create a chart, specify fields to be displayed on the category and series axes. Normally, the category axis displays data from numeric or non-numeric fields. The series axis displays data from numeric fields.
The Chart Designer supports creating only single-series charts. To create multi-series charts or comparison charts, we need to write the code.
Also we can Export and Import the Charts.
Note: We can create and attach charts to only those record types in Microsoft Dynamics CRM that support the new ribbon interface in the Web application. This is because all of the chart controls are only present in the ribbon interface of Microsoft Dynamics CRM.
We can create the charts from the CRM Views or by the Coding.
Create the Charts through CRM Views: You need to create the CRM view on the required Entity and then create the chart on this. As shown in the below screen shot we have create the view of all opportunity and then create the Sales Pipeline Chart for that view. As shown in the below screenshot.
Now open the Opportunity Entity and Create the Chart as shown in the below screenshot.
Create
the Chart by the Coding:
Below we have given that how to create the Sample Chart through Coding.
To create
the chart the Main things are the Fetch XML, Data XML and the Presentation XML.
1.
Fetch XML View: For creating the fetch xml view, you need to create the
Saved Query for that as given below.
savedquery newSavedQuery = new savedquery();
newSavedQuery.name =
"Sales Pipeline Funnel";
newSavedQuery.fetchxml
= @"
<fetch version='1.0'
output-format='xml-platform'
mapping='logical'
distinct='false'>
<entity name='opportunity'>
<attribute
name='name'/>
<attribute
name='customerid'/>
<attribute
name='estimatedvalue'/>
<attribute
name='statuscode'/>
<attribute
name='opportunityid'/>
<order
attribute='name' descending='false'/>
</entity>
</fetch>
";
newSavedQuery.returnedtypecode
= EntityName.opportunity.ToString();
newSavedQuery.layoutxml
= @"<grid name='resultset' object='3' jump='name'
select='1' icon='1'
preview='1'>
<row
name='result' id='opportunityid'>
<cell
name='name' width='300' />
<cell
name='customerid' width='150' />
<cell
name='estimatedvalue' width='100' />
<cell
name='statuscode' width='100' />
</row>
</grid>";
newSavedQuery.querytype
= new CrmNumber();
2. Presentation: Then you
need to write the following Presentation for that.
string presentationXml = @"
<Chart Palette='BrightPastel'>
<Series>
<Series _Template_='All' ShadowOffset='2'
BorderColor='64, 64, 64' BorderDashStyle='Solid'
BorderWidth='1' IsValueShownAsLabel='true'
Font='Tahoma, 6.75pt, GdiCharSet=0'
LabelForeColor='100, 100, 100'
CustomProperties='FunnelLabelStyle=Outside'
ChartType='Funnel'>
<SmartLabelStyle Enabled='True' />
<Points />
</Series>
</Series>
<ChartAreas>
<ChartArea _Template_='All' BackColor='Transparent'
BorderColor='Transparent' BorderDashStyle='Solid'>
<Area3DStyle Enable3D='True' IsClustered='True' />
</ChartArea>
</ChartAreas>
<Legends>
<Legend _Template_='All' Alignment='Center'
LegendStyle='Table' Docking='Bottom'
IsEquallySpacedItems='True' BackColor='White'
BorderColor='228, 228, 228' BorderWidth='0'
Font='Tahoma, 8pt, GdiCharSet=0'
ShadowColor='0, 0, 0, 0' ForeColor='100, 100, 100'>
</Legend>
</Legends>
<Titles>
<Title _Template_='All'
Font='Tahoma, 9pt, style=Bold, GdiCharSet=0'
ForeColor='102, 102, 102'>
</Title>
</Titles>
<BorderSkin PageColor='Control'
BackColor='CornflowerBlue'
BackSecondaryColor='CornflowerBlue' />
</Chart>";
3.
Data Xml:
Below we have created the Data XML for that. In the Data XML we need to provide
the Presentation and the Fetch XML view Id, as given below.
// Set the data XML string.
string dataXml = @"
<datadefinition>
<fetchcollection>
<fetch mapping='logical'
count='10'
aggregate='true'>
<entity name='opportunity'>
<attribute name='estimatedvalue_base'
aggregate='sum'
alias='sum_estimatedvalue_base'/>
<attribute name='stepname' groupby='true' alias='stepname'/>
<order alias='stepname' descending='false' />
</entity>
</fetch>
</fetchcollection>
<categorycollection>
<category>
<measurecollection>
<measure alias='sum_estimatedvalue_base'/>
</measurecollection>
</category>
</categorycollection>
</datadefinition>";
// Create the visualization entity instance.
savedqueryvisualization newSavedQueryVisualization = new savedqueryvisualization();
newSavedQueryVisualization.name = "Example Visualization";
newSavedQueryVisualization.presentationdescription = presentationXml;
newSavedQueryVisualization.datadescription = dataXml;
newSavedQueryVisualization.savedqueryid = new Lookup();
newSavedQueryVisualization.savedqueryid.Value = viewId;
Guid newSavedQueryVisualizationId = service.Create(newSavedQueryVisualization);
After doing the above things please call the
Publish request, As given below.
//Publish the Opportunity entity customizations.
PublishXmlRequest request = new PublishXmlRequest();
request.ParameterXml = @"
<importexportxml>
<entities>
<entity>opportunity</entity>
</entities>
<nodes/>
<securityroles/>
<settings/>
<workflows/>
</importexportxml>";
PublishXmlResponse response = (PublishXmlResponse)service.Execute(request);
Hello,
ReplyDeleteXmls with layout and fetch were not shown.
Kind regards,
Andrii.
This blog has been updated to include the Xmls..
ReplyDeleteHTH