<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dynamics crm Archives | ZappySys Blog</title>
	<atom:link href="https://zappysys.com/blog/tag/dynamics-crm/feed/" rel="self" type="application/rss+xml" />
	<link>https://zappysys.com/blog/tag/dynamics-crm/</link>
	<description>SSIS / ODBC Drivers / API Connectors for JSON, XML, Azure, Amazon AWS, Salesforce, MongoDB and more</description>
	<lastBuildDate>Thu, 11 Dec 2025 13:00:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.4</generator>

<image>
	<url>https://zappysys.com/blog/wp-content/uploads/2023/01/cropped-zappysys-symbol-large-32x32.png</url>
	<title>dynamics crm Archives | ZappySys Blog</title>
	<link>https://zappysys.com/blog/tag/dynamics-crm/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to register App for Dynamics CRM 365 / CDS / Dataverse API (Azure AD / OAuth)</title>
		<link>https://zappysys.com/blog/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Mon, 29 Nov 2021 21:20:53 +0000</pubDate>
				<category><![CDATA[SSIS Dynamics CRM Connection]]></category>
		<category><![CDATA[SSIS Dynamics CRM Destination]]></category>
		<category><![CDATA[SSIS Dynamics CRM Source]]></category>
		<category><![CDATA[d365]]></category>
		<category><![CDATA[dynamics crm]]></category>
		<category><![CDATA[Microsoft Dynamics 365]]></category>
		<category><![CDATA[oauth]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=9444</guid>

					<description><![CDATA[<p>Introduction In this article, we will show you step by step approach on how to register an Azure AD (Active Directory) app to access Dynamics CRM 365 API (also same for CDS / Dataverse API). You might have heard that Microsoft is deprecating an older way of authenticating (i.e. User ID / Password-based WS-Trust Authentication) [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth/">How to register App for Dynamics CRM 365 / CDS / Dataverse API (Azure AD / OAuth)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p>In this article, we will show you step by step approach on how to register an Azure AD (Active Directory) app to access Dynamics CRM 365 API (also same for CDS / Dataverse API). You might have heard that <a href="https://zappysys.zendesk.com/hc/en-us/articles/5258505448347">Microsoft is deprecating</a> an older way of authenticating (i.e. User ID / Password-based <strong>WS-Trust</strong> Authentication) on <strong>April 2022</strong>. You must update your jobs / code to use OAuth 2.0 by April 2022 for any CRM related API calls.</p>
<p>In other words rather than User Id / password now you can use more secure way by using <strong>OAuth</strong> rather than WS-Trust.</p>
<p>Going forward Microsoft wants you to use OAuth Token rather than user name/password to call Dynamics CRM 365 API programmatically.</p>
<p><a href="https://docs.microsoft.com/en-us/power-platform/important-changes-coming#deprecation-of-office365-authentication-type-and-organizationserviceproxy-class-for-connecting-to-dataverse" target="_blank" rel="noopener">Here is the official link which describes the dates for WS-Trust sunset</a></p>
<h2>Register App for CRM / CDS / Dataverse in Azure / Active Directory</h2>
<p>The first step is to register your app in Azure Portal under Active Directory using the below steps.</p>
<ol>
<li>Ask your Active Directory Admin to login to Azure Portal and navigate to &gt; <a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview" target="_blank" rel="noopener"><strong>Active Directory</strong></a> Blade.<br />
OR<br />
You can access it by searching &#8220;<strong>Azure Active directory</strong>&#8221; like below.</p>
<div id="attachment_9445" style="width: 403px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-9445" class="size-full wp-image-9445" src="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory.png" alt="Open Azure Active Directory" width="393" height="224" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory.png 393w, https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory-300x171.png 300w" sizes="(max-width: 393px) 100vw, 393px" /></a><p id="caption-attachment-9445" class="wp-caption-text">Open Azure Active Directory</p></div></li>
<li>Now click on the <a href="https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps" target="_blank" rel="noopener"><strong>App Registrations</strong></a> icon and click <strong><strong>New App Registration<br />
</strong></strong></p>
<div id="attachment_9446" style="width: 535px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory-new-app-registration.png"><img decoding="async" aria-describedby="caption-attachment-9446" class="size-full wp-image-9446" src="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory-new-app-registration.png" alt="New App Registrations under Azure Active Directory" width="525" height="275" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory-new-app-registration.png 525w, https://zappysys.com/blog/wp-content/uploads/2021/11/open-azure-active-directory-new-app-registration-300x157.png 300w" sizes="(max-width: 525px) 100vw, 525px" /></a><p id="caption-attachment-9446" class="wp-caption-text">New App Registrations under Azure Active Directory</p></div></li>
<li>Now next step is to give your <strong>App name</strong> to identify easily. Select App is used for your Org only option (Default) and last enter <strong>Redirect URL</strong> as below (This URL is used for 3-legged Authorization Code Grant only). We prefer you enter a URL which is OAuth friendly (If you don&#8217;t know one Use <pre class="crayon-plain-tag">https://zappysys.com/oauth</pre>  this is <strong>recommended</strong> URL if you working with ZappySys Products)
<div id="attachment_9447" style="width: 563px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/register-azure-active-directory-app-with-redirect-url.png"><img decoding="async" aria-describedby="caption-attachment-9447" class="size-full wp-image-9447" src="https://zappysys.com/blog/wp-content/uploads/2021/11/register-azure-active-directory-app-with-redirect-url.png" alt="Azure AD App Registration - Single / Multi Tenant with Redirect URl (i.e. Call back)" width="553" height="708" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/register-azure-active-directory-app-with-redirect-url.png 553w, https://zappysys.com/blog/wp-content/uploads/2021/11/register-azure-active-directory-app-with-redirect-url-234x300.png 234w" sizes="(max-width: 553px) 100vw, 553px" /></a><p id="caption-attachment-9447" class="wp-caption-text">Azure AD App Registration &#8211; Single / Multi-Tenant with Redirect URL (i.e. Call back)</p></div>
<p>&nbsp;</li>
<li>Now once App is created you can find the Application (Client) Id from overview page
<div id="attachment_10130" style="width: 633px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-find-application-client-id-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10130" class="wp-image-10130 size-full" src="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-find-application-client-id-1.png" alt="azure-ad-app-find-application-client-id" width="623" height="360" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-find-application-client-id-1.png 623w, https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-find-application-client-id-1-300x173.png 300w" sizes="(max-width: 623px) 100vw, 623px" /></a><p id="caption-attachment-10130" class="wp-caption-text">Azure AD App &#8211; Find Application / Client Id on overview page</p></div></li>
</ol>
<h2>Add API Permissions for the App</h2>
<p>Once App is created we need to Add Permission. Basically, we will set which style of APIs can be called by this App and what Actions can be performed.<br />
<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">For Apps specific to CRM / CDS / Dataverse API, actual app permissions are controlled by User Roles. Check later in this article how to associate one or more Roles to this AD App so it can perform certation actions via API call</div></div>
<ol>
<li>To add API Permissions for this AD App click on <strong>API Permissions</strong> and then click on <strong>Add Permission</strong>
<div id="attachment_9449" style="width: 439px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-add-api-permission.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9449" class="size-full wp-image-9449" src="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-add-api-permission.png" alt="Add API Permissions for Azure AD App" width="429" height="517" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-add-api-permission.png 429w, https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-add-api-permission-249x300.png 249w" sizes="(max-width: 429px) 100vw, 429px" /></a><p id="caption-attachment-9449" class="wp-caption-text">Add API Permissions for Azure AD App</p></div></li>
<li>Find the Dynamics CRM icon and click on it
<div id="attachment_9450" style="width: 669px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9450" class="size-full wp-image-9450" src="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm.png" alt="Add API Permission for Dynamics CRM API access (Azure AD App)" width="659" height="709" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm.png 659w, https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm-279x300.png 279w" sizes="(max-width: 659px) 100vw, 659px" /></a><p id="caption-attachment-9450" class="wp-caption-text">Add API Permission for Dynamics CRM API access (Azure AD App)</p></div></li>
<li>Now you will see just one permission for Dynamics CRM (user_impersonation). As we said earlier for Dynamics CRM API security is controlled by User Roles in CRM Portal itself which will see in the next section. For now, just choose <strong>Delegated Permissions</strong>,  check <strong>user_impersonation</strong> and click <strong>Add Permissions</strong>
<div id="attachment_9451" style="width: 661px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm-step2.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9451" class="size-full wp-image-9451" src="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm-step2.png" alt="Select API Permissions for Dynamics CRM App (Azure AD App)" width="651" height="608" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm-step2.png 651w, https://zappysys.com/blog/wp-content/uploads/2021/11/add-azure-ad-app-api-permission-dynamics-crm-step2-300x280.png 300w" sizes="(max-width: 651px) 100vw, 651px" /></a><p id="caption-attachment-9451" class="wp-caption-text">Select API Permissions for Dynamics CRM App (Azure AD App)</p></div></li>
<li>Now the last step in Adding API permissions is Grant Admin Consent. If you are logged in as an Azure AD User with the correct admin role then no worries else you have to ask your Azure AD admin to consent for you so this App can be used to read/write data from CRM.</li>
</ol>
<h2>Create Client Secret</h2>
<p>Once App is created next step is to generate a Client Secret. Perform the following steps to create a secret that you can use when you call API</p>
<ol>
<li>Click on Certificates and Secrets and then New Secret
<div id="attachment_9453" style="width: 1008px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-create-client-secret.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9453" class="size-full wp-image-9453" src="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-create-client-secret.png" alt="Azure AD App Create Client Secret / Set Name, Expiration Date" width="998" height="540" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-create-client-secret.png 998w, https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-create-client-secret-300x162.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-create-client-secret-768x416.png 768w" sizes="(max-width: 998px) 100vw, 998px" /></a><p id="caption-attachment-9453" class="wp-caption-text">Azure AD App Create Client Secret / Set Name, Expiration Date</p></div></li>
<li>Enter Name for Secret (You can give some friendly name if you create multiple secrets to control multiple processes). For example SecretForTesting, SecretForProduction etc.Select a longer expiration date (i.e. 24 months) if you don&#8217;t like to change secret often in production jobs else choose shorter expiration (i.e. 6 Months or Custom).</li>
<li>Once you Create a Secret make sure you copy it to a secure location. Once the page is closed it won&#8217;t appear again.
<div id="attachment_9454" style="width: 639px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-copy-client-secret-after-create.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9454" class="size-full wp-image-9454" src="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-copy-client-secret-after-create.png" alt="Copy Client Secret for Azure AD App" width="629" height="233" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-copy-client-secret-after-create.png 629w, https://zappysys.com/blog/wp-content/uploads/2021/11/azure-ad-app-copy-client-secret-after-create-300x111.png 300w" sizes="(max-width: 629px) 100vw, 629px" /></a><p id="caption-attachment-9454" class="wp-caption-text">Copy Client Secret for Azure AD App</p></div></li>
</ol>
<h2>Associate App User / Set Roles in CRM 365 / Dataverse Environment</h2>
<p>Once we have App Id and Client Secret we can go to CRM Portal to add our App as a valid CRM User. And the last step will be to attach some role(s) to App User (See Next section).</p>
<h3>Method-1 (New way)</h3>
<p>Here are the steps to configure User / Security Roles in New account. Below steps will give you access to Dataverse Entities via API Call. To see all Dataverse Entity you can log in to <a href="https://make.powerapps.com/" target="_blank" rel="noopener">https://make.powerapps.com/</a> and click <strong>Tables</strong></p>
<ol>
<li>Click on the below link to login to new portal to manage CRM /Dataverse environment<br />
<a href="https://admin.powerplatform.microsoft.com/environments" target="_blank" rel="noopener">https://admin.powerplatform.microsoft.com/environments</a></li>
<li>Create an Application User <a href="https://docs.microsoft.com/en-us/power-platform/admin/manage-application-users?WT.mc_id=ppac_inproduct_settings">using these steps</a> (When prompted choose the same App we created in the previous section)</li>
<li>Now Go to App Users Screen and Edit Security Roles using the below steps
<div id="attachment_9579" style="width: 698px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-environments.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9579" class="size-full wp-image-9579" src="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-environments.png" alt="See available CRM 365 Online / Datavese Environments" width="688" height="345" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-environments.png 688w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-environments-300x150.png 300w" sizes="(max-width: 688px) 100vw, 688px" /></a><p id="caption-attachment-9579" class="wp-caption-text">See available CRM 365 Online / Datavese Environments</p></div>
<div id="attachment_9580" style="width: 955px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-app-users.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9580" class="size-full wp-image-9580" src="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-app-users.png" alt="See available CRM 365 Online / Datavese Application Users" width="945" height="530" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-app-users.png 945w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-app-users-300x168.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-view-app-users-768x431.png 768w" sizes="(max-width: 945px) 100vw, 945px" /></a><p id="caption-attachment-9580" class="wp-caption-text">See available CRM 365 Online / Datavese Application Users</p></div>
<div id="attachment_9581" style="width: 1375px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9581" class="size-full wp-image-9581" src="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles.png" alt="Edit Security Roles for CRM 365 Online / Datavese Application Users" width="1365" height="581" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles.png 1365w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles-300x128.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles-768x327.png 768w, https://zappysys.com/blog/wp-content/uploads/2021/11/powerplatform-crm-365-online-dataverse-select-user-security-roles-1024x436.png 1024w" sizes="(max-width: 1365px) 100vw, 1365px" /></a><p id="caption-attachment-9581" class="wp-caption-text">Edit Security Roles for CRM 365 Online / Datavese Application Users</p></div></li>
</ol>
<h3>Method-2 (Legacy)</h3>
<p>If you prefer to use an older interface (and it&#8217;s still available to you) then you can use the below steps to perform the same thing we described in the previous section.</p>
<p>NOTE: Microsoft may soon retire the older interface and force to use the previous way only.</p>
<ol>
<li>To Add our Azure AD App as CRM Application user goto your CRM Portal. Click on <strong>Gear icon</strong> for Settings &gt; <strong>Advanced Settings</strong>
<div id="attachment_9456" style="width: 605px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-settings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9456" class="size-full wp-image-9456" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-settings.png" alt="Dynamics CRM Advanced Settings" width="595" height="344" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-settings.png 595w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-settings-300x173.png 300w" sizes="(max-width: 595px) 100vw, 595px" /></a><p id="caption-attachment-9456" class="wp-caption-text">Dynamics CRM Advanced Settings</p></div></li>
<li>Click on Settings dropdown &gt; <strong>Security</strong> (Under System Column)
<div id="attachment_9457" style="width: 826px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-security-settings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9457" class="size-full wp-image-9457" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-security-settings.png" alt="Dynamics CRM Security Settings (Under Advanced Settings - System)" width="816" height="438" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-security-settings.png 816w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-security-settings-300x161.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-advanced-security-settings-768x412.png 768w" sizes="(max-width: 816px) 100vw, 816px" /></a><p id="caption-attachment-9457" class="wp-caption-text">Dynamics CRM Security Settings (Under Advanced Settings &#8211; System)</p></div></li>
<li>On the security, screen click on the <strong><strong>Users icon<br />
</strong></strong></p>
<div id="attachment_9458" style="width: 396px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-users.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9458" class="size-full wp-image-9458" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-users.png" alt="Manage Dynamics CRM Users / Roles (Add, Edit, Delete)" width="386" height="269" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-users.png 386w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-users-300x209.png 300w" sizes="(max-width: 386px) 100vw, 386px" /></a><p id="caption-attachment-9458" class="wp-caption-text">Manage Dynamics CRM Users (Add, Edit, Delete)</p></div></li>
<li>Once User Screen shows up click on the User Type <strong>Dropdown</strong> and choose <strong>Application Users</strong> and click <strong>New</strong>
<div id="attachment_9455" style="width: 425px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-365-add-new-application-user.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9455" class="size-full wp-image-9455" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-365-add-new-application-user.png" alt="Add new Application User in Dynamics CRM" width="415" height="305" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-365-add-new-application-user.png 415w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-365-add-new-application-user-300x220.png 300w" sizes="(max-width: 415px) 100vw, 415px" /></a><p id="caption-attachment-9455" class="wp-caption-text">Add new Application User in Dynamics CRM</p></div></li>
<li>Once User screen shows up. Enter your <strong>Application Id</strong> (obtained from the Azure AD App &gt; Overview screen &#8211; app created earlier). <strong>Click Save</strong> and you will notice all other fields auto populates.
<div id="attachment_10132" style="width: 681px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/create-dynamics-crm-application-user-link-azure-ad-app-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10132" class="wp-image-10132 size-full" src="https://zappysys.com/blog/wp-content/uploads/2021/11/create-dynamics-crm-application-user-link-azure-ad-app-1.png" alt="create-dynamics-crm-application-user-link-azure-ad-app" width="671" height="835" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/create-dynamics-crm-application-user-link-azure-ad-app-1.png 671w, https://zappysys.com/blog/wp-content/uploads/2021/11/create-dynamics-crm-application-user-link-azure-ad-app-1-241x300.png 241w" sizes="(max-width: 671px) 100vw, 671px" /></a><p id="caption-attachment-10132" class="wp-caption-text">Adding Azure AD App as Dynamics CRM 365 &#8211; Application User</p></div></li>
<li>And the last step is to Attach some CRM Role to the new Application User.<div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF8B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">For demo purposes we will choose &#8220;System Admin&#8221; but for production use, you should grant correct permission carefully. There are many inbuilt roles you can choose from.</div></div>
<div id="attachment_10133" style="width: 893px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-application-user-roles-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10133" class="wp-image-10133 size-full" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-application-user-roles-1.png" alt="dynamics-crm-manage-application-user-roles" width="883" height="766" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-application-user-roles-1.png 883w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-application-user-roles-1-300x260.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/dynamics-crm-manage-application-user-roles-1-768x666.png 768w" sizes="(max-width: 883px) 100vw, 883px" /></a><p id="caption-attachment-10133" class="wp-caption-text">Associate Security Role(s) for Dynamics CRM Application User</p></div></li>
</ol>
<h2></h2>
<h2>Find your Organization Id for CRM / Dataverse API calls</h2>
<p>Now find your Org Id before we can call CRM / Dataverse APIs in the next section.</p>
<p>To find your Org Id you can perform the following steps.</p>
<p><strong>Method-1 (New way &#8211; Dataverse Portal)</strong></p>
<ol>
<li>Go to <a href="https://admin.powerplatform.microsoft.com/" target="_blank" rel="noopener">https://admin.powerplatform.microsoft.com/</a></li>
<li>Click on the Environment you like to access</li>
<li>On the Details, page copy your Org Id from the Environment URL For example URL might look like below&#8230; You just need to copy the first part (Use this on CRM Connection &gt; Organization Field)<br />
<span style="text-decoration: underline;"><strong>org8640f7e7</strong></span>.crm.dynamics.com</p>
<div id="attachment_10134" style="width: 752px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/microsoft-dataverse-crm-api-get-organization-id-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10134" class="wp-image-10134 size-full" src="https://zappysys.com/blog/wp-content/uploads/2021/11/microsoft-dataverse-crm-api-get-organization-id-1.png" alt="microsoft-dataverse-crm-api-get-organization-id" width="742" height="424" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/microsoft-dataverse-crm-api-get-organization-id-1.png 742w, https://zappysys.com/blog/wp-content/uploads/2021/11/microsoft-dataverse-crm-api-get-organization-id-1-300x171.png 300w" sizes="(max-width: 742px) 100vw, 742px" /></a><p id="caption-attachment-10134" class="wp-caption-text">How to find Organization Id for Microsoft Dataverse / CDS / CRM 365 API calls</p></div></li>
</ol>
<p><strong>Method-2 (Old way)</strong></p>
<p>Another way to find your Organization Id is from CRM Portal</p>
<p>If you have multiple environments (i.e. Prod, Sandbox) then each environment might have its own unique URL)</p>
<ol>
<li>To find your API Service URL, Click on <strong>Gear Icon</strong></li>
<li>Choose <strong>Advanced Settings</strong></li>
<li>Click down arrow on <strong>Settings</strong></li>
<li>Click <strong>Customization</strong></li>
<li>Click <strong>Developer Resource</strong> Link</li>
<li>On this page now you can see various URLs. For examples used in this article, we need to get is <strong>Service Root URL</strong> for <strong><strong>Web API</strong></strong>
<div id="attachment_10125" style="width: 730px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10125" class="wp-image-10125 size-large" src="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-1024x626.png" alt="dynamics-crm-find-organization-url-soap-web-api" width="720" height="440" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-1024x626.png 1024w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-300x183.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-768x469.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1.png 1028w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-10125" class="wp-caption-text">How to Find Organization Id / Web API URL / SOAP API Service URL (Unique Environment Instance URL)</p></div></li>
</ol>
<h2>Using Client ID (i.e. App Id) and Client Secret to Call Dynamics CRM 365 API / CDS / Dataverse</h2>
<p>That&#8217;s it now we are ready to use this App Id and Client Secret to make CRM API calls.</p>
<p>To confirm if it&#8217;s working you can create a Dynamics CRM Connection (using <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">SSIS PowerPack</a> ). Choose OAuth option on <a href="https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/" target="_blank" rel="noopener">Dynamics CRM Connection</a></p>
<div id="attachment_9543" style="width: 899px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9543" class="size-full wp-image-9543" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png" alt="Connect to Dynamics CRM / Dataverse / PowerApps API using OAuth (Client ID /Secret)" width="889" height="646" srcset="https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png 889w, https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api-300x218.png 300w, https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api-768x558.png 768w" sizes="(max-width: 889px) 100vw, 889px" /></a><p id="caption-attachment-9543" class="wp-caption-text">Connect to Dynamics CRM / Dataverse / PowerApps API using OAuth (Client ID /Secret)</p></div>
<h2>Conclusion</h2>
<p>In this article, we saw how to Register Azure AD App to call various Microsoft APIs (for this article we focused mainly on Dynamics CRM 365 API only)</p>
<p>The post <a href="https://zappysys.com/blog/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth/">How to register App for Dynamics CRM 365 / CDS / Dataverse API (Azure AD / OAuth)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to read Microsoft Dynamics 365 OData API data in SSIS (CRM Web API)</title>
		<link>https://zappysys.com/blog/read-microsoft-dynamics-365-odata-api-data-ssis/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Sat, 25 May 2019 10:28:13 +0000</pubDate>
				<category><![CDATA[SSIS JSON Source (File/REST)]]></category>
		<category><![CDATA[365]]></category>
		<category><![CDATA[CRM 365]]></category>
		<category><![CDATA[dynamics crm]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[Microsoft Dynamics 365]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[oauth2]]></category>
		<category><![CDATA[odata]]></category>
		<category><![CDATA[ssis]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=7004</guid>

					<description><![CDATA[<p>Introduction In our previous article, we talked about how to read from Dynamics CRM using easy to use SSIS Dynamics CRM Source connector. In this post, you will learn how to use SSIS JSON Source (for REST API) instead of CRM Source. Using SSIS JSON Source you can read virtually any REST API or JSON file data including Dynamics CRM [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/read-microsoft-dynamics-365-odata-api-data-ssis/">How to read Microsoft Dynamics 365 OData API data in SSIS (CRM Web API)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" class="wp-image-3577 size-thumbnail alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300-150x150.png" alt="" width="150" height="150" /></a>In our previous article, we talked about how to <a href="https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/" target="_blank" rel="noopener">read from Dynamics CRM</a> using easy to use <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-source-connector/" target="_blank" rel="noopener">SSIS Dynamics CRM Source connector</a>. In this post, you will learn how to use <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">SSIS JSON Source (for REST API)</a> instead of CRM Source. Using SSIS JSON Source you can read virtually any REST API or JSON file data including Dynamics CRM / Dataverse. For this article, our goal is to learn <strong>How to read Microsoft Dynamics 365 data using Web API (OData API) in SSIS.</strong> We will use drag and drop approach without any coding.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><strong>Why use Web API (OAuth) for Dynamics 365 CRM?</strong></h2>
<p>Microsoft has announced depreciation of older CRM API (SOAP API with WS-Trust Authentication) which means they are no longer going to support the older style of authentication so no option but to switch to newer authentication / API.</p>
<p>In the older approach (SOAP API with WS-Trust Authentication) you must pass your User Name and Password to authenticate, also if MFA / 2FA (Multi-Factored Auth) is turned on by organization policy you cannot use your user id / password in API call. In new authentication (i.e. OAuth) you have to use Client Id and Client Secret only.</p>
<p>Now let&#8217;s look at the step by step approach to call Dynamics 365 REST API.</p>
<h2>Step-1 : Register Dynamics CRM / Dataverse App obtain App Id / Client Secret</h2>
<p>The very first step to access Microsoft Dynamics CRM 365 API is to obtain Application Id (also referred as Client Id)  and Client Secret. We will use this information later in this article (on OAuth connection UI).</p>
<ol>
<li><a href="https://zappysys.com/blog/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth/" target="_blank" rel="noopener">Register Dynamics CRM / Dataverse App With Azure</a> and get the credential (App Id, Client Secret).</li>
</ol>
<h2></h2>
<h2>Step-2 : Read Microsoft Dynamics 365 API data in SSIS using JSON Source</h2>
<p>Let&#8217;s start with an example. We use SSIS JSON Source Task to make calls to Microsoft Dynamics 365 API, we will load Dynamics 365 Leads data to SQL Server.</p>
<p>Please refer to this link for more information: <a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/about?view=dynamics-ce-odata-9" target="_blank" rel="noopener">Microsoft Dynamics 365 Web API Reference</a></p>
<h3>Find out API Url for your environment (organization url)</h3>
<p>Once we are done with the creation of the Azure AD app to obtain App Id /Secret out next step is to find out the base API URL for your organization / environment.</p>
<p>If you have multiple environments (i.e. Prod, Sandbox) then each environment might have its own unique URL)</p>
<ol>
<li>To find your API Service URL, Click on <strong>Gear Icon</strong></li>
<li>Choose <strong>Advanced Settings</strong></li>
<li>Click down arrow on <strong>Settings</strong></li>
<li>Click <strong>Customization</strong></li>
<li>Click <strong>Developer Resource</strong> Link</li>
<li>On this page now you can see various URLs. For examples used in this article, we need to get is <strong>Service Root URL</strong> for <strong>Web API</strong></li>
</ol>
<div id="attachment_10125" style="width: 730px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10125" class="wp-image-10125 size-large" src="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-1024x626.png" alt="dynamics-crm-find-organization-url-soap-web-api" width="720" height="440" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-1024x626.png 1024w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-300x183.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1-768x469.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/dynamics-crm-find-organization-url-soap-web-api-1.png 1028w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-10125" class="wp-caption-text">How to Find Organization Id / Web API URL / SOAP API Service URL (Unique Environment Instance URL)</p></div>
<p>&nbsp;</p>
<h3>Create SSIS Data Flow to read data from Dynamics CRM / Dataverse</h3>
<ol>
<li>
        First of All, Drag and drop Data Flow Task from SSIS Toolbox and double click it to edit.<img class="yoast-text-mark" /></p>
<p>        <div id="attachment_7934" style="width: 470px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/09/ssis-drag-drop-data-flow-task.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7934" class="wp-image-7934 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/09/ssis-drag-drop-data-flow-task.png" alt="Drag and Drop SSIS Data Flow Task from SSIS Toolbox" width="460" height="155" srcset="https://zappysys.com/blog/wp-content/uploads/2019/09/ssis-drag-drop-data-flow-task.png 460w, https://zappysys.com/blog/wp-content/uploads/2019/09/ssis-drag-drop-data-flow-task-300x101.png 300w" sizes="(max-width: 460px) 100vw, 460px" /></a><p id="caption-attachment-7934" class="wp-caption-text">Drag and Drop SSIS Data Flow Task from SSIS Toolbox</p></div>
    </li>
<li>
        Furthermore, Drag and Drop JSON Source(REST API and File) File Task from the SSIS Toolbox.<img class="yoast-text-mark" /></p>
<p>        <div id="attachment_3766" style="width: 604px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3766" class="size-full wp-image-3766" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png" alt="Drag and Drop JSON Source Component" width="594" height="268" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin.png 594w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-json-source-for-getting-basic-profile-from-linkedin-300x135.png 300w" sizes="(max-width: 594px) 100vw, 594px" /></a><p id="caption-attachment-3766" class="wp-caption-text">Drag and Drop JSON Source Component</p></div>
    </li>
</ol>
<h3></h3>
<h3>Create OAuth Connection for Dynamics CRM / Dataverse</h3>
<p>Now lets look at how to create and configure OAuth connection to call Web API for Dynamics CRM / Dataverse</p>
<ol>
<li>
        Check Use Credentials Option and select a new ZS-OAuth Connection from the drop-down.</p>
<p>        <div id="attachment_7689" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-check-use-credentials-select-connection.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7689" class="wp-image-7689 size-medium_large" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-check-use-credentials-select-connection-768x593.png" alt="Check Use Credentials " width="720" height="556" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-check-use-credentials-select-connection-768x593.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-check-use-credentials-select-connection-300x232.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-check-use-credentials-select-connection.png 823w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-7689" class="wp-caption-text">Check Use Credentials</p></div>
    </li>
<li>
        Once OAuth Connection UI opens up. Configure like below on General Tab.<br />
        Change OAuth Version to <strong>OAuth2</strong><br />
        Change Grant Type to <strong>Client Credentials</strong><br />
        Enter <strong>Client Id</strong> (Azure AD App Id) (Obtained in the Previous Section)<br />
        Enter <strong>Client Secret</strong> (Obtained in the Previous Section)<br />
        Enter <strong>Token URL</strong> (see below)</p>
<div id="attachment_10127" style="width: 616px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-oauth-client-credentials-grant-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10127" class="wp-image-10127 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-oauth-client-credentials-grant-1.png" alt="azure-ad-app-oauth-client-credentials-grant" width="606" height="351" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-oauth-client-credentials-grant-1.png 606w, https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-oauth-client-credentials-grant-1-300x174.png 300w" sizes="(max-width: 606px) 100vw, 606px" /></a><p id="caption-attachment-10127" class="wp-caption-text">Configure OAuth Connection for Azure AD App &#8211; Client Credentials Grant (Tenant Specific Token EndPoints)</p></div>
<p>        <span style="text-decoration: underline;"><strong>For Client Credentials Grant</strong></span><br />
        Enter Token URL as <strong>https://login.microsoftonline.com/<span style="color: #0000ff;">&lt;your-tenant-id&gt;</span>/oauth2/token</strong><br />
        (You can find Tenant ID on the Overview page of your Azure AD App)</p>
<p>        <span style="text-decoration: underline;"><strong>For Default Grant (3-legged &#8211; requires User Login Prompt)</strong></span><br />
        Enter Auth URL as <strong>https://login.microsoftonline.com/common/oauth2/authorize</strong><br />
        Enter Token  URL as <strong><strong>https://login.microsoftonline.com/common/oauth2/token</strong></strong></p>
<p>        &nbsp;</p>
<div id="attachment_10128" style="width: 858px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-10128" class="wp-image-10128 size-full" src="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1.png" alt="azure-ad-app-token-url-with-tenant-id-oauth-v1" width="848" height="448" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1.png 848w, https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1-300x158.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1-768x406.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/azure-ad-app-token-url-with-tenant-id-oauth-v1-1-720x380.png 720w" sizes="(max-width: 848px) 100vw, 848px" /></a><p id="caption-attachment-10128" class="wp-caption-text">Where to find Token Endpoint with Tenant ID in the URL (Azure AD App)</p></div>
<p>        &nbsp;
    </li>
<li>
        Now go to Advanced Tab and configure like belowEnter <strong>Extra Attribute for /auth</strong> as  <pre class="crayon-plain-tag">resource=https://&lt;your-instance-id&gt;.api.&lt;your-crm-region&gt;.dynamics.com</pre>
<p>        <div id="attachment_9471" style="width: 595px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/resource-dyanmics-crm-connection-for-cleint-cred-token.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-9471" class="size-full wp-image-9471" src="https://zappysys.com/blog/wp-content/uploads/2019/05/resource-dyanmics-crm-connection-for-cleint-cred-token.png" alt="Client Credentials Grant for Dynamics CRM / Dataverse - API Access (Azure AD App / OAuth)" width="585" height="254" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/resource-dyanmics-crm-connection-for-cleint-cred-token.png 585w, https://zappysys.com/blog/wp-content/uploads/2019/05/resource-dyanmics-crm-connection-for-cleint-cred-token-300x130.png 300w" sizes="(max-width: 585px) 100vw, 585px" /></a><p id="caption-attachment-9471" class="wp-caption-text">Client Credentials Grant for Dynamics CRM / Dataverse &#8211; API Access (Azure AD App / OAuth)</p></div>
    </li>
<li>Click OK to Save connection.</li>
</ol>
<h3>Get all Accounts, Contacts, and Leads using Dynamics 365 API</h3>
<p>Now let&#8217;s configure API URL from where you like to read data.</p>
<p>For example, if you just use the root URL then it will list all possible entries</p>
<p>Root URL: <pre class="crayon-plain-tag">https://{{organization-uri}}/api/data/v9.1/</pre>
<ol>
<li>Double click on the Component to Edit the Configurations.</li>
<li>Change Data Format to <strong>OData</strong>.</li>
<li>
        In the Web URL Field, you can enter any valid URL for Web API. Please refer to this link of <a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/account?view=dynamics-ce-odata-9" target="_blank" rel="noopener">Dynamics 365 Rest API</a> for more information.<strong>Example Data URLs</strong></p><pre class="crayon-plain-tag">https://{{organization-uri}}/api/data/v9.1/
https://{{organization-uri}}/api/data/v9.1/accounts
https://{{organization-uri}}/api/data/v9.1/contacts
https://{{organization-uri}}/api/data/v9.1/leads</pre><p>
        Here, replace <strong>{{organization-uri}} </strong>in URL to your Microsoft Dynamics 365 site domain name (Example <strong><span style="text-decoration: underline;">zappy6.api.crm.dynamics.com</span></strong> Dynamics 365 URL)<strong>.</strong></p>
<p>        <div id="attachment_7211" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-D365-API-set-url-json-source.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7211" class="wp-image-7211 size-medium_large" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-D365-API-set-url-json-source-768x682.png" alt="Set URL in JSON Source" width="720" height="639" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-D365-API-set-url-json-source-768x682.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-D365-API-set-url-json-source-300x266.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-D365-API-set-url-json-source.png 826w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-7211" class="wp-caption-text">Set URL in JSON Source</p></div>
    </li>
</ol>
<h3>Preview / Query Dynamics 365 Data</h3>
<ol>
<li>Now select Array filter as <pre class="crayon-plain-tag">$.value[*]</pre>  (Click <strong>Select Filter</strong> Button &#8211; Choose value node)</li>
<li>
        Click on the Preview button to get the data.</p>
<p>        <div id="attachment_7687" style="width: 730px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-json-source-preview-dynamic-crm.png" target="_blank" rel="noopener"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-7687" class="wp-image-7687 size-medium_large" src="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-json-source-preview-dynamic-crm-768x631.png" alt="Preview Data" width="720" height="592" srcset="https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-json-source-preview-dynamic-crm-768x631.png 768w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-json-source-preview-dynamic-crm-300x246.png 300w, https://zappysys.com/blog/wp-content/uploads/2019/05/ssis-json-source-preview-dynamic-crm.png 891w" sizes="(max-width: 720px) 100vw, 720px" /></a><p id="caption-attachment-7687" class="wp-caption-text">Preview Data</p></div>
    </li>
<li>Finally, click OK to save JSON Source settings.</li>
<li>That’s it we are ready to load Dynamics 365 API data to SQL Server.</li>
</ol>
<h3>Load Microsoft Dynamics 365 API data into SQL Server</h3>
<div class="content_block" id="custom_post_widget-5617"><p>ZappySys SSIS PowerPack makes it easy to load data from various sources such as REST, SOAP, JSON, XML, CSV or from other source into SQL Server, or PostgreSQL, or Amazon Redshift, or other  targets. The <strong>Upsert Destination</strong> component allows you to automatically insert new records and update existing ones based on key columns. Below are the detailed steps to configure it.</p>
<h3>Step 1: Add Upsert Destination to Data Flow</h3>
<ol>
<li>Drag and drop the <strong>Upsert Destination</strong> component from the SSIS Toolbox.</li>
<li>Connect your source component (e.g., JSON / REST / Other Source) to the Upsert Destination.</li>
</ol>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2017/08/ssis-data-flow-drag-drop-upsert-destination.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2017/08/ssis-data-flow-drag-drop-upsert-destination.png" /></a>
<p class="wp-caption-text">SSIS - Data Flow - Drang and Drop Upsert Destination Component</p>
</div>
<h3>Step 2: Configure Target Connection</h3>
<ol>
<li>Double-click the <strong>Upsert Destination</strong> component to open the configuration window.</li>
<li>Under <strong>Connection</strong>, select an existing target connection or click <strong>NEW</strong> to create a new connection.
<ul>
<li>Example: SQL Server, or PostgreSQL, or Amazon Redshift.</li>
</ul>
</li>
</ol>
<h3>Step 3: Select or Create Target Table</h3>
<ol>
<li>In the <strong>Target Table</strong> dropdown, select the table where you want to load data.</li>
<li>Optionally, click <strong>NEW</strong> to create a new table based on the source columns.</li>
</ol>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-configuration.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-configuration.png" /></a>
<p class="wp-caption-text">Configure SSIS Upsert Destination Connection - Loading data (REST / SOAP / JSON / XML /CSV) into SQL Server or other target using SSIS</p>
</div>
<h3>Step 4: Map Columns</h3>
<ol>
<li>Go to the <strong>Mappings</strong> tab.</li>
<li>Click <strong>Auto Map</strong> to map source columns to target columns by name.</li>
<li>Ensure you <strong>check the Primary key column(s)</strong> that will determine whether a record is inserted or updated.</li>
<li>You can manually adjust the mappings if necessary.</li>
</ol>
 <div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-key.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2020/09/upsert-destination-key.png" /></a>
<p class="wp-caption-text">SSIS Upsert Destination - Columns Mappings</p>
</div>
<h3>Step 5: Save Settings</h3>
<ul>
<li>Click <strong>OK</strong> to save the Upsert Destination configuration.</li>
</ul>
<h3>Step 6: Optional: Add Logging or Analysis</h3>
<ul>
<li>You may add extra destination components to log the number of inserted vs. updated records for monitoring or auditing purposes.</li>
</ul>
<h3>Step 7: Execute the Package</h3>
<ul>
<li>Run your SSIS package and verify that the data is correctly inserted and updated in the target table.</li>
</ul>
<div class="wp-caption aligncenter">
<a href="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-upsert-destination-execute.png">
<img loading="lazy" decoding="async" class="size-full" alt="" src="https://zappysys.com/blog/wp-content/uploads/2018/12/ssis-upsert-destination-execute.png" /></a>
<p class="wp-caption-text">SSIS Upsert Destination Execution</p>
</div></div>
<h2><span id="Conclusion">Conclusion</span></h2>
<p>In this post you have seen how to Read Microsoft Dynamics 365 API data in SSIS. We used <a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source Component</a> to call Dynamics 365 REST API and load data into SQL server. You can <a href="https://zappysys.com/products/ssis-powerpack/">download SSIS PowerPack here</a> to try many other scenarios not discussed in this blog along with 70+ other components.</p>
<h2><span id="References">References</span></h2>
<p>Finally, you can use the following links for more information about the use of Dynamics 365 REST API with our tools:</p>
<ul>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-json-file-source/" target="_blank" rel="noopener">JSON Source</a>, you can also find <a href="https://youtu.be/t4fSghbSZLo" target="_blank" rel="noopener">Tutorial Video</a> here.</li>
<li><strong>Help File:</strong> Documentation of <a href="https://zappysys.com/onlinehelp/ssis-powerpack/index.htm#page=json-source.htm" target="_blank" rel="noopener">SSIS Json Source</a></li>
<li><a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/about?view=dynamics-ce-odata-9" target="_blank" rel="noopener">Microsoft Dynamics CRM Web API Reference</a></li>
<li><a href="https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/entitytypes?view=dynamics-ce-odata-9" target="_blank" rel="noopener">Dynamics 365 Web API EntityType Reference</a></li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The post <a href="https://zappysys.com/blog/read-microsoft-dynamics-365-odata-api-data-ssis/">How to read Microsoft Dynamics 365 OData API data in SSIS (CRM Web API)</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Load data into Dynamics CRM using SSIS &#8211; Insert, Upsert, Delete, Update</title>
		<link>https://zappysys.com/blog/load-dynamics-crm-using-ssis-insert-upsert-delete-update/</link>
		
		<dc:creator><![CDATA[ZappySys]]></dc:creator>
		<pubDate>Thu, 05 Jul 2018 19:20:32 +0000</pubDate>
				<category><![CDATA[SSIS Dynamics CRM Destination]]></category>
		<category><![CDATA[dynamics crm]]></category>
		<category><![CDATA[office 365]]></category>
		<category><![CDATA[ssis]]></category>
		<category><![CDATA[upsert]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=4318</guid>

					<description><![CDATA[<p>Introduction In our previous article, we talked about how to read from Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp). Now let&#8217;s look at how to Load data into Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) using SSIS. We will see a few important aspects of loading data into Dynamics [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/load-dynamics-crm-using-ssis-insert-upsert-delete-update/">Load data into Dynamics CRM using SSIS &#8211; Insert, Upsert, Delete, Update</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300.png"><img loading="lazy" decoding="async" class=" wp-image-3577 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300.png" alt="" width="104" height="94" /></a>In our previous article, we talked about how to <a href="https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/" target="_blank" rel="noopener">read from Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp)</a>. Now let&#8217;s look at how to Load data into Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) using SSIS. We will see a few important aspects of loading data into Dynamics CRM / Dataverse Online (i.e. Dynamics 365) and On-premises / IFD (Internet facing hosted instance).</p>
<p>We will show you how to use <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-destination-connector/" target="_blank" rel="noopener">SSIS Dynamics CRM Destination</a> connector for Bulk Insert, Update, Delete and Upsert Operations. This article uses Dynamics 365 Online for CRM Integration Examples but concepts are same for other types of installation (e.g. IFD or On-Premises)</p>
<h2>Requirements</h2>
<ol>
<li>Make sure you have SSIS Designer installed (i.e. <a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt?view=sql-server-2017" target="_blank" rel="noopener">SSDT-BI</a>)</li>
<li>Download and Installed <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a> which includes an SSIS Dynamics CRM Connectors.</li>
<li>Finally, make sure you have Microsoft Dynamics CRM / Dataverse credentials handy.</li>
</ol>
<p>That&#8217;s it. So let&#8217;s get started.</p>
<h2>Video Tutorial &#8211; CRM Insert, Upsert, Delete, Update</h2>
<a href="https://zappysys.com/blog/load-dynamics-crm-using-ssis-insert-upsert-delete-update/"><img decoding="async" src="https://zappysys.com/blog/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FfBbRzTcd3fk%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>
<p>&nbsp;</p>
<h2>Getting Started</h2>
<p>In this section, we will see how to perform bulk insert, update delete and upsert operations using  <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-destination-connector/" target="_blank" rel="noopener">SSIS Dynamics CRM Destination</a></p>
<h3>Configure SSIS Dynamics CRM / Dataverse Connection</h3>
<p>The first step to read or write Dynamics CRM / Dataverse data is to make sure we have working Dynamics CRM connection in SSIS.</p>
<ol>
<li>Create new or open existing SSIS Project in Visual Studio.</li>
<li>Open SSIS Package and Go to SSIS designer.</li>
<li>
        Right click in the connection manager panel and click <strong>New connection</strong>:</p>
<p>        <div id="attachment_3560" style="width: 756px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3560" class="size-full wp-image-3560" src="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg" alt="SSIS create a new connection CRM Dynamics" width="746" height="403" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg 746w, https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection-300x162.jpg 300w" sizes="(max-width: 746px) 100vw, 746px" /></a><p id="caption-attachment-3560" class="wp-caption-text">Create a new SSIS Dynamics CRM / Dataverse Connection</p></div>
    </li>
<li>In the connection type selection, Select the <strong>ZS-DYNAMICS-CRM</strong> Connection.</li>
<li>
        We will use a <strong>CRM Online</strong> (Office 365) connection, <strong>region</strong>, a <strong>username</strong> and a <strong>password</strong> and select <strong>organization</strong> from the dropdown as below and then click <strong>Test connection</strong>:</p>
<p>        <div id="attachment_3559" style="width: 775px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-credentials-zs.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3559" class="size-full wp-image-3559" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-credentials-zs.jpg" alt="SSIS Dynamics CRM / Dataverse credentials" width="765" height="633" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-credentials-zs.jpg 765w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-credentials-zs-300x248.jpg 300w" sizes="(max-width: 765px) 100vw, 765px" /></a><p id="caption-attachment-3559" class="wp-caption-text">Configure Dynamics CRM / Dataverse Connection in SSIS</p></div>
    </li>
</ol>
<h3></h3>
<h3>Bulk Insert &#8211; SQL Server data Import into Dynamics CRM / Dataverse using SSIS</h3>
<p>Now, let&#8217;s see steps to do SQL Server data Import into Dynamics CRM / Dataverse using SSIS. Below steps assume you already have sample data in some SQL Server Table which will be used to create new CRM accounts. You can enter few account names you like to create in the CRM.</p>
<ol>
<li>Open SSIS Package and drag Data Flow task from Control Flow SSIS Toolbox</li>
<li>Go to data flow designer. Drag and drop OLEDB Source</li>
<li>
        Configure OLEDB Source to read from some sample data table (e.g. dbo.Accounts). If you want to be lazy and just test quickly you can use <a href="https://zappysys.com/products/ssis-powerpack/ssis-csv-file-source-flat-file-web-api/" target="_blank" rel="noopener">ZS CSV Source</a> (Direct Value Mode) instead of OLEDB Source.<strong>Sample Data May be like below</strong><br />
<pre class="crayon-plain-tag">name,address1_city,address1_country
Flipkart,Bengaluru,India
Microsoft,seattle,USA
Nokia,Espoo,Finland</pre>
        Once you configure Source (Connection, Table Name etc.) click OK to save it.</p>
<p>        <div id="attachment_4351" style="width: 785px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-insert-accounts-to-dynamics-crm-online-365.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4351" class="size-full wp-image-4351" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-insert-accounts-to-dynamics-crm-online-365.png" alt="CSV Source - Sample Accounts for CRM Insert Demo" width="775" height="602" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-insert-accounts-to-dynamics-crm-online-365.png 775w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-insert-accounts-to-dynamics-crm-online-365-300x233.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-insert-accounts-to-dynamics-crm-online-365-768x597.png 768w" sizes="(max-width: 775px) 100vw, 775px" /></a><p id="caption-attachment-4351" class="wp-caption-text">CSV Source &#8211; Sample Accounts for CRM Insert Demo</p></div>
    </li>
<li>Drag and drop  <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-destination-connector/" target="_blank" rel="noopener">ZS Dynamics CRM Destination</a> from the toolbox.</li>
<li>Connect Source to your Destination component.</li>
<li>Double click CRM destination to configure it.</li>
<li>
        On the Connection Managers tab, Select Dynamics CRM / Dataverse connection we created in the previous section.</p>
<p>        <div id="attachment_4353" style="width: 526px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-select-connection.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4353" class="size-full wp-image-4353" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-select-connection.png" alt="Select Connection for Dynamics CRM / Dataverse Destination" width="516" height="286" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-select-connection.png 516w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-select-connection-300x166.png 300w" sizes="(max-width: 516px) 100vw, 516px" /></a><p id="caption-attachment-4353" class="wp-caption-text">Select Connection for Dynamics CRM / Dataverse Destination</p></div>
    </li>
<li>
        On the Component Properties Tab Select <strong>Table Name</strong>.</p>
<p>        <div id="attachment_4354" style="width: 807px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-insert-records-settings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4354" class="size-full wp-image-4354" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-insert-records-settings.png" alt="Select Target Table for Dynamics CRM / Dataverse Insert" width="797" height="429" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-insert-records-settings.png 797w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-insert-records-settings-300x161.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-insert-records-settings-768x413.png 768w" sizes="(max-width: 797px) 100vw, 797px" /></a><p id="caption-attachment-4354" class="wp-caption-text">Select Target Table for Dynamics CRM / Dataverse Insert</p></div>
    </li>
<li>
        On the Mapping Tab map few columns (e.g.  <strong>name</strong>, <strong>address1_city, </strong>and <strong><strong><strong>address1_country)</strong></strong></strong></p>
<p>        <div id="attachment_4355" style="width: 792px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4355" class="size-full wp-image-4355" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings.png" alt="Configure Target Column Mapping for CRM Data Load" width="782" height="519" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings.png 782w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings-300x199.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings-768x510.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-target-column-mappings-272x182.png 272w" sizes="(max-width: 782px) 100vw, 782px" /></a><p id="caption-attachment-4355" class="wp-caption-text">Configure Target Column Mapping for CRM Data Load</p></div>
    </li>
<li>Click OK to save CRM destination.</li>
<li>
        Right click in the data flow designer, click Execute Task</p>
<p>        <div id="attachment_4356" style="width: 519px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-loading-data-into-dynamics-crm-online.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4356" class="wp-image-4356 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-loading-data-into-dynamics-crm-online.png" alt="Execute SSIS Package - Import into Dynamics CRM / Dataverse using SSIS " width="509" height="224" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-loading-data-into-dynamics-crm-online.png 509w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-loading-data-into-dynamics-crm-online-300x132.png 300w" sizes="(max-width: 509px) 100vw, 509px" /></a><p id="caption-attachment-4356" class="wp-caption-text">Execute SSIS Package &#8211; Loading Data into Dynamics CRM / Dataverse from CSV / SQL Server</p></div>
    </li>
</ol>
<h3>Bulk Upsert &#8211; Update or Insert Dynamics CRM / Dataverse Records in SSIS</h3>
<p>In the previous section we saw how to Insert New records. However sometimes you want to Upsert (Insert or Update). So if record already exists Update else Insert. In order to achieve this you have to set two additional attributes. For CRM Upsert you have to perform few changes to previous steps</p>
<h4>Create Alternate Key for CRM Upsert</h4>
<p>To perform Upsert operation you can map Table&#8217;s Primary Key or Alternate Key. Primary Key usually starts with table name and ends with &#8220;id&#8221; (e.g. for account table its accountid ).</p>
<p>Many times Source system don&#8217;t have CRM Table Primary Key. In such case you may use Alternate Key in the mapping (JOIN Key). To use Alternate key for Upsert you have first define Alternate Key in CRM Portal. <a href="https://technet.microsoft.com/library/29e53691-0b18-4fde-a1d0-7490aa227898.aspx" target="_blank" rel="noopener">Check this link for exact steps</a>.</p>
<div id="attachment_4359" style="width: 1056px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4359" class="size-full wp-image-4359" src="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data.png" alt="Create Alternate Key for Dynamics CRM / Dataverse Online Table (Useful for Update or Upsert Operation)" width="1046" height="522" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data.png 1046w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data-300x150.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data-768x383.png 768w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data-1024x511.png 1024w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-365-create-alternate-key-upsert-records-update-insert-data-960x480.png 960w" sizes="(max-width: 1046px) 100vw, 1046px" /></a><p id="caption-attachment-4359" class="wp-caption-text">Create Alternate Key for Dynamics CRM / Dataverse Online Table (Useful for Update or Upsert Operation)</p></div>
<h4>Configure SSIS CRM Destination for Upsert</h4>
<ol>
<li>Double click CRM destination. On the Component Properties Tab, Change Operation to <strong>UpdateOrInsert</strong></li>
<li>
        Specify <strong>UpsertKeyField</strong> to either Table&#8217;s Primary Key Column Name or Alternate Key Name.</p>
<p>        <div id="attachment_4360" style="width: 932px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-update-insert-use-alternate-key-field.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4360" class="size-full wp-image-4360" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-update-insert-use-alternate-key-field.png" alt="Dynamics CRM / Dataverse Upsert using SSIS CRM Destination (Specify Alternate Key / Primary Key)" width="922" height="740" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-update-insert-use-alternate-key-field.png 922w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-update-insert-use-alternate-key-field-300x241.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-update-insert-use-alternate-key-field-768x616.png 768w" sizes="(max-width: 922px) 100vw, 922px" /></a><p id="caption-attachment-4360" class="wp-caption-text">Dynamics CRM / Dataverse Upsert Records using SSIS CRM Destination (Specify Alternate Key / Primary Key)</p></div>
    </li>
<li>
        Now go to Mappings tab and confirm Key field is mapped.</p>
<p>        <div id="attachment_4361" style="width: 866px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-mappings.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4361" class="size-full wp-image-4361" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-mappings.png" alt="Configure Dynamics CRM / Dataverse Mapping for Upsert in SSIS" width="856" height="642" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-mappings.png 856w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-mappings-300x225.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-upsert-mappings-768x576.png 768w" sizes="(max-width: 856px) 100vw, 856px" /></a><p id="caption-attachment-4361" class="wp-caption-text">Configure Dynamics CRM / Dataverse Mapping for Upsert in SSIS</p></div>
    </li>
<li>Click OK and Run Package to test CRM Upsert Operation.</li>
</ol>
<p>&nbsp;</p>
<div class="su-note"  style="border-color:#e5dd9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#FFF7B7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">If you want to use primary key for Upsert or Update Operation and not sure correct column name then you may use <a href="//zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-source-connector/" target="_blank" rel="noopener">ZappySys Dynamics CRM / Dataverse Source</a> FetchXml Query Mode and check Object Browser (Table Info Tab &gt;&gt; <strong>PrimaryIdAttribute</strong> in the grid).</p>
<p>Primary Key name usually starts with table name and ends with &#8220;id&#8221; (e.g. for account table its <strong>accountid</strong> ).</p>
<div id="attachment_4358" style="width: 602px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-find-primarykey-column.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4358" class=" wp-image-4358" src="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-find-primarykey-column.png" alt="Find Primary Key for Dynamics CRM / Dataverse Table" width="592" height="424" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-find-primarykey-column.png 792w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-find-primarykey-column-300x215.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/dynamics-crm-find-primarykey-column-768x550.png 768w" sizes="(max-width: 592px) 100vw, 592px" /></a><p id="caption-attachment-4358" class="wp-caption-text">Find Primary Key for Dynamics CRM / Dataverse Table</p></div>
</div></div>
<h4>Handling Inserted / Updated Records Output</h4>
<p>Now lets look at how to detect which records got inserted and which records got Update? In Upsert Mode each record can be directed to one of the following three Outputs.</p>
<ul>
<li>Inserted Records [Blue Arrow]</li>
<li>Updated Records [Blue Arrow]</li>
<li>Records with Error [Red Arrow]</li>
</ul>
<p>You can select Red or Blue arrow coming out from CRM Destination component. Drag and drop output arrow on any down stream component.</p>
<h3>Bulk Update &#8211; Modify Dynamics CRM / Dataverse Records in SSIS</h3>
<p>If you want to do bulk Update its very same steps as Upsert Operation except you have to set <strong>Operation = Update</strong> in the properties grid. For Key field you have to set primary key or Alternate Key.</p>
<div id="attachment_4362" style="width: 482px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-update-records.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4362" class="size-full wp-image-4362" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-update-records.png" alt="Dynamics CRM / Dataverse Update in SSIS" width="472" height="474" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-update-records.png 472w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-update-records-150x150.png 150w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-update-records-300x300.png 300w" sizes="(max-width: 472px) 100vw, 472px" /></a><p id="caption-attachment-4362" class="wp-caption-text">Dynamics CRM / Dataverse Update in SSIS</p></div>
<h3>Bulk Delete &#8211; Delete Dynamics CRM / Dataverse Records in SSIS</h3>
<p>Bulk delete doesn&#8217;t require many settings. All you have to change is <strong>Operation = Delete</strong> on Component Properties Screen. On the Mapping Screen Map only one column (Primary Key). If you are not sure which one is primary key please refer to the previous section (Upsert Operation).</p>
<div id="attachment_4363" style="width: 687px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-delete.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4363" class="size-full wp-image-4363" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-delete.png" alt="Delete records from Dynamics CRM / Dataverse Online using SSIS (Primary Key mapping for CRM Bulk Delete)" width="677" height="483" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-delete.png 677w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-delete-300x214.png 300w" sizes="(max-width: 677px) 100vw, 677px" /></a><p id="caption-attachment-4363" class="wp-caption-text">Delete records from Dynamics CRM / Dataverse Online using SSIS (Primary Key mapping for CRM Bulk Delete)</p></div>
<p>Some times you may get below errors. If you get this error make sure you delete all child records first before deleting parent. For example if you are deleting account then make sure you have to delete leads / contacts for that account or update leads / contacts so they don&#8217;t refer to account being deleted.</p><pre class="crayon-plain-tag">Error: 0xC0047062 at Dynamics CRM / Dataverse Bulk Delete, Delete Accounts [2]: System.Exception: Exception: The object you tried to delete is associated with another object and cannot be deleted.
Error Details: 
ApiExceptionSourceKey=Plugin/Microsoft.Crm.Common.ObjectModel.AccountService</pre><p>
<h2>Error Handling</h2>
<p>Many times you want to ignore bad records and continue processing good records. In such case you can use Dynamics CRM / Dataverse Error Output. Just grad Red arrow from CRM Destination and Drop on target component. Select Redirect Option for Error , Truncation both and Click OK.</p>
<p>Once you set Error Handling your component will continue to run without failing whole data flow. Later you can review errors (if you saving to destination).</p>
<div id="attachment_4364" style="width: 863px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-configure-error-output.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4364" class="size-full wp-image-4364" src="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-configure-error-output.png" alt="Configure Error Handling in SSIS Dynamics CRM / Dataverse Destination" width="853" height="801" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-configure-error-output.png 853w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-configure-error-output-300x282.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/ssis-dynamics-crm-destination-configure-error-output-768x721.png 768w" sizes="(max-width: 853px) 100vw, 853px" /></a><p id="caption-attachment-4364" class="wp-caption-text">Configure Error Handling in SSIS Dynamics CRM / Dataverse Destination</p></div>
<p>&nbsp;</p>
<div id="attachment_4365" style="width: 853px" class="wp-caption alignnone"><a href="https://zappysys.com/blog/wp-content/uploads/2018/07/insert-dynamics-crm-records-ssis.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4365" class="size-full wp-image-4365" src="https://zappysys.com/blog/wp-content/uploads/2018/07/insert-dynamics-crm-records-ssis.png" alt="Loading records into Dynamics CRM / Dataverse Table using SSIS . Redirect Bad rows to Error Output." width="843" height="422" srcset="https://zappysys.com/blog/wp-content/uploads/2018/07/insert-dynamics-crm-records-ssis.png 843w, https://zappysys.com/blog/wp-content/uploads/2018/07/insert-dynamics-crm-records-ssis-300x150.png 300w, https://zappysys.com/blog/wp-content/uploads/2018/07/insert-dynamics-crm-records-ssis-768x384.png 768w" sizes="(max-width: 843px) 100vw, 843px" /></a><p id="caption-attachment-4365" class="wp-caption-text">Loading records into Dynamics CRM / Dataverse Table using SSIS . Redirect Bad rows to Error Output.</p></div>
<h2>Handling Special Data Types (PartyList, Lookup, PickList)</h2>
<p>Certain datatypes in CRM requires special handling. <a href="https://zappysys.zendesk.com/hc/en-us/articles/360004361833-How-to-handle-Dynamics-CRM-PartyList-Lookup-and-PickList-datatypes-in-SSIS" target="_blank" rel="noopener">Check this article</a> to learn more about how to insert data into columns with <strong>PartyList</strong>, <strong>Lookup</strong> or <strong>PickList</strong> field.</p>
<h2>Conclusion</h2>
<p>In this article, We have seen how easy it is to integrate SQL Server data with Dynamics CRM / Dataverse. Using drag and drop connector you can perform Bulk insert, update, delete and Upsert operations. Download <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a> to learn more about other possible scenarios which are not discussed in this article.</p>
<p>The post <a href="https://zappysys.com/blog/load-dynamics-crm-using-ssis-insert-upsert-delete-update/">Load data into Dynamics CRM using SSIS &#8211; Insert, Upsert, Delete, Update</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SSIS Dynamics CRM / Dataverse &#8211; Read / Import data into SQL Server</title>
		<link>https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/</link>
		
		<dc:creator><![CDATA[ZappySys Team]]></dc:creator>
		<pubDate>Tue, 15 May 2018 20:36:40 +0000</pubDate>
				<category><![CDATA[SSIS Dynamics CRM Source]]></category>
		<category><![CDATA[dynamics crm]]></category>
		<category><![CDATA[office 365]]></category>
		<category><![CDATA[ssis]]></category>
		<guid isPermaLink="false">https://zappysys.com/blog/?p=3504</guid>

					<description><![CDATA[<p>Introduction Today Microsoft Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) is one of the most popular CRMs in the world. SSIS Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) read operation can be achieved using Dynamics CRM / Dataverse Source Connector. It allows connecting to Dynamics CRM / [&#8230;]</p>
<p>The post <a href="https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/">SSIS Dynamics CRM / Dataverse &#8211; Read / Import data into SQL Server</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300.png"><img loading="lazy" decoding="async" class=" wp-image-3577 alignleft" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-365-logo-300x300.png" alt="" width="178" height="160" /></a>Today Microsoft Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) is one of the most popular CRMs in the world. SSIS Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) read operation can be achieved using <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-source-connector/" target="_blank" rel="noopener">Dynamics CRM / Dataverse Source Connector</a>. It allows connecting to <strong>Dynamics CRM / Dataverse 365 Online</strong> or <strong>On-Premises Installation</strong> / <strong>Hosted</strong> CRM instance (IFD &#8211; internet facing deployment). You can read data from Dynamics CRM / Dataverse using SSIS connector and then exports to other sources (e.g. SQL Server, Oracle or Flat File).</p>
<p>In this new article, we will show how to connect and download the Dynamics CRM / Dataverse 365 (Online) data using <a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-source-connector/" target="_blank" rel="noopener">Dynamics CRM / Dataverse Source Connector</a>, how to query CRM data using <strong>FetchXML</strong> in SSIS and how to use variables in CRM FetchXML Query.</p>
<p>&nbsp;</p>
<h2>Requirements for SSIS Dynamics CRM / Dataverse (Dynamics 365 / On-Premises CRM / PowerApp) read component</h2>
<ol>
<li>First, you will need SSDT installed</li>
<li>Second, You will need to install <a href="https://zappysys.com/products/ssis-powerpack/" target="_blank" rel="noopener">ZappySys SSIS PowerPack</a> which includes an SSIS Dynamics CRM / Dataverse Source (Dynamics 365 / On-Premises CRM / PowerApp) task.</li>
<li>Finally, a Microsoft Dynamics account</li>
</ol>
<h2>SSIS Dynamics CRM / Dataverse Source &#8211; Video Tutorial</h2>
[youtube https://www.youtube.com/watch?v=zl0ecdjuLGk?rel=0&amp;showinfo=0&amp;w=560&amp;h=315]
<h2>Getting started with SSIS Dynamics CRM / Dataverse read component</h2>
<h3>Register Dynamics CRM / Dataverse App obtain App Id / Client Secret</h3>
<p>The very first step to access Microsoft Dynamics CRM / Dataverse 365 API is to obtain Application Id (also referred as Client Id)  and Client Secret. We will use this information later in this article (on OAuth connection UI).<br />
<a href="https://zappysys.com/blog/register-app-dynamics-crm-365-cds-dataverse-api-azure-ad-oauth/" target="_blank" rel="noopener">Register Dynamics CRM / Dataverse App With Azure</a> and get the credential (App Id, Client Secret).</p>
<h3>Configure Dynamics CRM / Dataverse Connection</h3>
<ol>
<li>
        In the connection manager, press the new button to create a new connection:</p>
<p>        <div id="attachment_3560" style="width: 756px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3560" class="size-full wp-image-3560" src="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg" alt="SSIS create a new connection CRM Dynamics" width="746" height="403" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection.jpg 746w, https://zappysys.com/blog/wp-content/uploads/2018/05/create-a-new-connection-300x162.jpg 300w" sizes="(max-width: 746px) 100vw, 746px" /></a><p id="caption-attachment-3560" class="wp-caption-text">SSIS create a new connection CRM Dynamics</p></div>
    </li>
<li>
        Select the ZS-DYNAMICS-CRM Connection.  We will use a CRM Online connection, username, password, and organization:<br />
        <div class="su-note"  style="border-color:#e5de9d;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;"><div class="su-note-inner su-u-clearfix su-u-trim" style="background-color:#fff8b7;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;">NOTE: Please check the Discovery and ORG Service URL are the same as your organization URL. And if you are using Customize URL make sure that you are using it in both Discovery URL as well as in ORG Service URL also.</div></div>
<p>        <div id="attachment_3559" style="width: 775px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3559" class="size-full wp-image-3559" src="https://zappysys.com/blog/wp-content/uploads/2021/11/dyanamics-crm-connection-using-oauth-clientid-connect-dataverse-api.png" alt="SSIS Dynamics CRM / Dataverse credentials" width="765" height="633" /></a><p id="caption-attachment-3559" class="wp-caption-text">SSIS Dynamics CRM / Dataverse credentials</p></div>
    </li>
</ol>
<h3>How to create a Dynamics CRM / Dataverse Source</h3>
<ol>
<li>In the control flow, drag and drop the data flow:<img loading="lazy" decoding="async" class="alignnone size-full" src="https://zappysys.com/onlinehelp/ssis-powerpack/scr/images/drag-and-drop-data-flow-task.png" width="460" height="155" /></li>
<li>
        Drag and drop the ZS Dynamics CRM / Dataverse Source:</p>
<p>        <div id="attachment_3510" style="width: 653px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-dynamics-crm-source.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3510" class="size-full wp-image-3510" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-dynamics-crm-source.jpg" alt="ssis Dynamics CRM / Dataverse source" width="643" height="392" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-dynamics-crm-source.jpg 643w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-dynamics-crm-source-300x183.jpg 300w" sizes="(max-width: 643px) 100vw, 643px" /></a><p id="caption-attachment-3510" class="wp-caption-text">SSIS Dynamics CRM / Dataverse source</p></div>
    </li>
<li>
        Second, select the connection created before and select the account table:</p>
<div id="attachment_3509" style="width: 896px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3509" class="size-full wp-image-3509" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account.jpg" alt="ssis entity table account" width="886" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account.jpg 886w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-300x204.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-768x523.jpg 768w" sizes="(max-width: 886px) 100vw, 886px" /></a><p id="caption-attachment-3509" class="wp-caption-text">SSIS entity table account</p></div>
<p>        &nbsp;
    </li>
</ol>
<h3>Configure SQL Server Destination</h3>
<p>In the following example, we will show how to export the data from the account entity to SQL Server.</p>
<ol>
<li>
        First, drag and drop the OLEDB Destination and join with our ZS CRM Dynamics source:</p>
<p>        <div id="attachment_3516" style="width: 334px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-source-dynamics-sql-destination.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3516" class="size-full wp-image-3516" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-source-dynamics-sql-destination.jpg" alt="ssis source dynamics sql destination" width="324" height="202" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-source-dynamics-sql-destination.jpg 324w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-source-dynamics-sql-destination-300x187.jpg 300w" sizes="(max-width: 324px) 100vw, 324px" /></a><p id="caption-attachment-3516" class="wp-caption-text">SSIS source dynamics SQL destination</p></div>
    </li>
<li>
        Make sure to select the account table from Dynamics:</p>
<p>        <div id="attachment_3517" style="width: 896px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-1.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3517" class="size-full wp-image-3517" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-1.jpg" alt="ssis entity table account" width="886" height="603" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-1.jpg 886w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-1-300x204.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-entity-table-account-1-768x523.jpg 768w" sizes="(max-width: 886px) 100vw, 886px" /></a><p id="caption-attachment-3517" class="wp-caption-text">SSIS Dynamics CRM / Dataverse read entity table account</p></div>
    </li>
<li>
        In addition, select an SQL Server and a database. In the name of the table, we will create a table with the following columns:<br />
<pre class="crayon-plain-tag">CREATE TABLE [crm dynamics] (
[accountcategorycode] nvarchar(255),

[accountid] uniqueidentifier,
[accountnumber] nvarchar(20),
[accountratingcode] nvarchar(255),
[accountratingcodename] nvarchar(255),
[address1_addressid] uniqueidentifier,
[address1_city] nvarchar(80),

)</pre>
        <div id="attachment_3548" style="width: 834px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-oledb.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3548" class="size-full wp-image-3548" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-oledb.jpg" alt="ssis oledb sql server" width="824" height="719" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-oledb.jpg 824w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-oledb-300x262.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-oledb-768x670.jpg 768w" sizes="(max-width: 824px) 100vw, 824px" /></a><p id="caption-attachment-3548" class="wp-caption-text">SSIS OLEBD SQL Server</p></div>
    </li>
<li>
        Go to the mapping page to map all the source and destination columns:</p>
<p>        <div id="attachment_3518" style="width: 834px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-import-data.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3518" class="wp-image-3518 size-full" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-import-data.jpg" alt="dynamics import data SSIS Dynamics CRM / Dataverse read" width="824" height="663" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-import-data.jpg 824w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-import-data-300x241.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-import-data-768x618.jpg 768w" sizes="(max-width: 824px) 100vw, 824px" /></a><p id="caption-attachment-3518" class="wp-caption-text">SSIS Dynamics CRM / Dataverse read mapping</p></div>
    </li>
</ol>
<h3>Load Dynamics CRM / Dataverse Data to SQL Server</h3>
<ol>
<li>
        Execute the package:</p>
<p>        <div id="attachment_3563" style="width: 703px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-start-package.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3563" class="size-full wp-image-3563" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-start-package.jpg" alt="ssis start package" width="693" height="79" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-start-package.jpg 693w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-start-package-300x34.jpg 300w" sizes="(max-width: 693px) 100vw, 693px" /></a><p id="caption-attachment-3563" class="wp-caption-text">SSIS start package</p></div>
    </li>
<li>Finally, you can see the data exported in SQL Server. Select the data from the CRM Dynamics table:</li>
</ol>
<div id="attachment_3519" style="width: 661px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-results.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3519" class="size-full wp-image-3519" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-results.jpg" alt="Data exported from crm to sql server" width="651" height="275" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-results.jpg 651w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-results-300x127.jpg 300w" sizes="(max-width: 651px) 100vw, 651px" /></a><p id="caption-attachment-3519" class="wp-caption-text">Data exported from SSIS Dynamic CRM read</p></div>
<h2>How to query Dynamics CRM / Dataverse</h2>
<p>You can query Dynamics CRM / Dataverse data in two modes (Table mode or Query Mode). To use query mode you have to use a special language called <a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx" target="_blank" rel="noopener">FetchXML</a> (sorry no SQL support).  FetchXML is an XML based query language which can be used to SELECT, FILTER, Aggregate, Transform data from CRM. Not all features from traditional SQL Language Found in FetchXML but basic query features can be implemented by writing FetchXML. Here is an example of typical FetchXML.</p><pre class="crayon-plain-tag">&lt;fetch mapping="logical" version="1.0"&gt;
  &lt;entity name="account"&gt;
    &lt;attribute name="accountid" /&gt;
    &lt;attribute name="name" /&gt;
    &lt;attribute name="country" /&gt;
    &lt;filter&gt;
      &lt;condition attribute="country" operator="in"&gt;
        &lt;value&gt;USA&lt;/value&gt;
        &lt;value&gt;UK&lt;/value&gt;
        &lt;value&gt;INDIA&lt;/value&gt;
      &lt;/condition&gt;
      &lt;condition attribute="status" operator="like" value="ACT%" /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
Above FetchXML query is equivalent to below SQL query in traditional RDBMS.</p><pre class="crayon-plain-tag">SELECT accountid,name,country 
FROM account
WHERE country IN ('USA','UK','INDIA') 
AND status LIKE 'ACT%'</pre><p>
&nbsp;</p>
<p>Now let&#8217;s look at how to build FetchXML queries by UI or by Hand.</p>
<p>&nbsp;</p>
<h3>How to generate a FetchXML query using UI</h3>
<ol>
<li>
        The Dynamics CRM / Dataverse portal contains an option to create queries visually that can be exported to XML. To do that use the <strong>Advanced Find</strong> option in the portal:</p>
<p>        <div id="attachment_3564" style="width: 1370px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3564" class="size-full wp-image-3564" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml.jpg" alt="Dynamics CRM / Dataverse fetch xml" width="1360" height="403" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml.jpg 1360w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml-300x89.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml-768x228.jpg 768w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-fetch-xml-1024x303.jpg 1024w" sizes="(max-width: 1360px) 100vw, 1360px" /></a><p id="caption-attachment-3564" class="wp-caption-text">Dynamics CRM / Dataverse fetch XML</p></div>
    </li>
<li>
        For example, we will query the Accounts entity where the account name is A. Datum:</p>
<p>        <div id="attachment_3565" style="width: 889px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-365-crm-Create-a-query.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3565" class="size-full wp-image-3565" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-365-crm-Create-a-query.jpg" alt="dynamics 365 crm Create a query" width="879" height="303" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-365-crm-Create-a-query.jpg 879w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-365-crm-Create-a-query-300x103.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-365-crm-Create-a-query-768x265.jpg 768w" sizes="(max-width: 879px) 100vw, 879px" /></a><p id="caption-attachment-3565" class="wp-caption-text">dynamics 365 CRM Create a query</p></div>
    </li>
<li>
        Next, we can download the Fetch XML:</p>
<p>        <div id="attachment_3566" style="width: 798px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-xml-download.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3566" class="size-full wp-image-3566" src="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-xml-download.jpg" alt="Dynamics CRM / Dataverse xml download" width="788" height="312" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-xml-download.jpg 788w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-xml-download-300x119.jpg 300w, https://zappysys.com/blog/wp-content/uploads/2018/05/dynamics-crm-xml-download-768x304.jpg 768w" sizes="(max-width: 788px) 100vw, 788px" /></a><p id="caption-attachment-3566" class="wp-caption-text">Dynamics CRM / Dataverse xml download</p></div>
    </li>
</ol>
<p>Let’s check some examples about fetch XML:</p>
<h3>SELECT All Columns (*)</h3>
<p>This example shows how to write a simple FetchXML query to select all columns<br />
of the account entity.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT * FROM account</pre><p>
The option all-attributes show all the attributes. In this case, of the account entity.</p>
<p>To build custom FetxhXML:<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
 &lt;entity name='account'&gt;
 &lt;all-attributes /&gt;
 &lt;/entity&gt;  
 &lt;/fetch&gt;</pre><p>
<h3>SELECT Specified Columns and Alias with SSIS Dynamics CRM / Dataverse</h3>
<p>This example shows how to write a simple FetchXML query to select two columns and use an alias for column name (e.g. name is renamed to accountname).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT accountid, name as accountname
FROM account</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical'&gt; 
	&lt;entity name='account'&gt;
		&lt;attribute name='accountid'/&gt; 
		&lt;attribute name='name' alias = 'accountname'/&gt; 
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>WHERE (AND conditions)</h3>
<p>This example shows how to write FetchXML query to filter data using multiple conditions (AND).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT * FROM account WHERE revenue &gt; 0 AND name like 'A%'</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.<br />
For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
	&lt;entity name='account'&gt;
		&lt;all-attributes /&gt;
		&lt;filter&gt;
			&lt;condition attribute='revenue' operator='gt' value='0' /&gt;
			&lt;condition attribute='name' operator='like' value='A%' /&gt;
		&lt;/filter&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>WHERE (OR conditions)</h3>
<p>This example shows how to write FetchXML query to filter data using multiple conditions (OR).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT * FROM account WHERE revenue &gt; 0 OR name like 'A%'</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.<br />
For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
	&lt;entity name='account'&gt;
		&lt;all-attributes /&gt;
		&lt;filter type='or'&gt;
			&lt;condition attribute='revenue' operator='gt' value='0' /&gt;
			&lt;condition attribute='name' operator='like' value='A%' /&gt;
		&lt;/filter&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>WHERE (Mixing AND / OR conditions)</h3>
<p>This example shows how to write FetchXML query to filter data using multiple conditions (Mixing AND / OR).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT * FROM account 
WHERE revenue &gt; 0 AND
    (
     name LIKE 'A%' OR 
     name LIKE 'B%'
    )</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.<br />
For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
	&lt;entity name='account'&gt;
		&lt;all-attributes /&gt;
		&lt;filter&gt;
			&lt;condition attribute='revenue' operator='gt' value='0' /&gt;
			&lt;filter type='or'&gt;
				&lt;condition attribute='name' operator='like' value='A%' /&gt;
				&lt;condition attribute='name' operator='like' value='B%' /&gt;
			&lt;/filter&gt;
		&lt;/filter&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>SELECT DISTINCT (Exclude duplicates)</h3>
<p>This example shows how to write FetchXML query to get distinct records (exclude duplicates).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT DISTINCT accountid,name FROM account</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links:<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' distinct='true' version='1.0'&gt;
	&lt;entity name='account'&gt; 
		&lt;attribute name='accountid' /&gt;
		&lt;attribute name='name' /&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>SELECT TOP using SSIS Dynamics CRM / Dataverse read</h3>
<p>This example shows how to write FetchXML query to select TOP N rows. This setting may not work if you using preview mode.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT TOP 10 * FROM account</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' count='10' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;all-attributes /&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>GROUP BY / Aggregate functions</h3>
<p>This example shows how to use aggregate functions such as SUM, MIN, MAX, AVG along with GROUP BY clause. When you use the Aggregate function in SQL Query you can also use an alias for the field. Refer FetchXML help to learn more about aggregate functions.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT AVG(estimatedvalue) AS estimatedvalue_avg, COUNT(name) AS opportunity_count, ownerid AS ownerid
FROM opportunity 
GROUP BY ownerid</pre><p>
You can use COUNT, COUNT(attribute_name), SUM, MIN, MAX, AVG as an aggregate function</p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch distinct='false' mapping='logical' aggregate='true'&gt; 
    &lt;entity name='opportunity'&gt; 
       &lt;attribute name='estimatedvalue' aggregate='avg' alias='estimatedvalue_avg'  /&gt; 
       &lt;attribute name='name' aggregate='countcolumn' alias='opportunity_count' /&gt; 
       &lt;attribute name='ownerid' alias='ownerid' groupby='true' /&gt; 
    &lt;/entity&gt; 
&lt;/fetch&gt;</pre><p>
<h3>INNER JOIN (matching child records)</h3>
<p>This example shows how to write FetchXML query to get account and associated contacts where email is @gmail.com or yahoo.com or hotmail.com and revenue for account is &gt; 10000.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT a.name, c.firstname, c.lastname, c.email
FROM account a
INNER JOIN contact c ON a.accountid=c.parentcustomerid
                     AND (c.email LIKE '%@yahoo.com'
                          OR c.email LIKE '%@gmail.com'
                          OR c.email LIKE '%@hotmail.com')
WHERE a.revenue &gt; 10000</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='gt' value='10000' /&gt;
    &lt;/filter&gt;
    &lt;link-entity name='contact' from='parentcustomerid' to='accountid' alias='c' link-type='inner'&gt;
      &lt;attribute name='firstname' /&gt;
      &lt;attribute name='lastname' /&gt;
      &lt;attribute name='email' /&gt;
      &lt;filter type='or'&gt;
        &lt;condition attribute='email' operator='like' value='%@yahoo.com' /&gt;
        &lt;filter type='or'&gt;
          &lt;condition attribute='email' operator='like' value='%@gmail.com' /&gt;
          &lt;condition attribute='email' operator='like' value='%@hotmail.com' /&gt;
        &lt;/filter&gt;
      &lt;/filter&gt;
    &lt;/link-entity&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>LEFT OUTER JOIN (&#8216;not in&#8217; type query)</h3>
<p>This example shows how to write FetchXML query to find all leads that have no tasks, using an alias.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT lead.FullName
FROM Leads as lead
LEFT OUTER JOIN Tasks as ab
    ON (lead.leadId  =  ab.RegardingObjectId)
WHERE ab.RegardingObjectId is null</pre><p>
For more information on left outer join syntax check below link<br />
<a href="https://msdn.microsoft.com/en-us/library/dn531006.aspx">https://msdn.microsoft.com/en-us/library/dn531006.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'&gt;
  &lt;entity name='lead'&gt;
    &lt;attribute name='fullname' /&gt;
    &lt;link-entity name='task' from='regardingobjectid' to='leadid' alias='ab' link-type='outer'&gt;
       &lt;attribute name='regardingobjectid' /&gt;
    &lt;/link-entity&gt;
    &lt;filter type='and'&gt;
        &lt;condition entityname='ab' attribute='regardingobjectid' operator='null' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;fetch/&gt;</pre><p>
<h3>ORDER BY</h3>
<p>This example shows how to write FetchXML query with order by specified for one or more attributes.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT firstname, lastname, email FROM contact
ORDER BY lastname ASC, firstname DESC</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='contact'&gt;
    &lt;attribute name='firstname' /&gt;
    &lt;attribute name='lastname' /&gt;
    &lt;attribute name='email' /&gt;
    &lt;order attribute='lastname' /&gt;
    &lt;order attribute='firstname' descending='true' /&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; Equal ( = )</h3>
<p>This example shows how to write FetchXML query using equal operator.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE revenue=0</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='eq' value='0' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch</pre><p>
<h3>OPERATOR &#8211; Not Equal ( != )</h3>
<p>This example shows how to write FetchXML query using not equal operator.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE revenue != 0</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='ne' value='0' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; Greater Than ( &gt; )</h3>
<p>This example shows how to write FetchXML query using greater than the operator.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE revenue &gt; 0</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='gt' value='0' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; Less Than ( &lt; )</h3>
<p>This example shows how to write FetchXML query using greater than the operator.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE revenue &lt; 0</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='lt' value='0' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; IN (Check for multiple matching values)</h3>
<p>This example shows how to write FetchXML query to find multiple matching values using IN operator.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE name IN ('Microsoft', 'Yahoo', 'Google')</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='name' operator='in'&gt;
        &lt;value&gt;Microsoft&lt;/value&gt;
        &lt;value&gt;Yahoo&lt;/value&gt;
        &lt;value&gt;Google&lt;/value&gt;
      &lt;/condition&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; NULL (Check for NULL values)</h3>
<p>This example shows how to write FetchXML query to find NULL values (search for records where email not specified).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT firstname, lastname, email FROM contact WHERE email is NULL</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='contact'&gt;
    &lt;attribute name='firstname' /&gt;
    &lt;attribute name='lastname' /&gt;
    &lt;attribute name='email' /&gt;	
    &lt;filter&gt;
      &lt;condition attribute='email' operator='null' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; NOT NULL (Check for NOT NULL values)</h3>
<p>This example shows how to write FetchXML query to find NOT NULL values (search for records where email not specified).</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT firstname, lastname, email FROM contact WHERE email is NOT NULL</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='contact'&gt;
    &lt;attribute name='firstname' /&gt;
    &lt;attribute name='lastname' /&gt;
    &lt;attribute name='email' /&gt;	
    &lt;filter&gt;
      &lt;condition attribute='email' operator='not-null' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; LIKE (Pattern search)</h3>
<p>This example shows how to write FetchXML query using LIKE operator to match string by pattern search.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE name LIKE 'zappy%'</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='name' operator='like' value='zappy%' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; NOT LIKE (Pattern search)</h3>
<p>This example shows how to write FetchXML query using LIKE operator to match string by pattern search.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT name FROM account WHERE name NOT LIKE 'zappy%'</pre><p>
For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='name' operator='not-like' value='zappy%' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>OPERATOR &#8211; UNDER (Find all children for given hierarchy) with the SSIS Dynamics CRM / Dataverse read task</h3>
<p>This example shows how to write FetchXML query to get children count for a given hierarchy.</p>
<p>For more information about querying hierarchical data check below link<br />
<a href="https://msdn.microsoft.com/en-us/library/dn817893.aspx">https://msdn.microsoft.com/en-us/library/dn817893.aspx</a></p>
<p>For a list of supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch distinct='false' no-lock='false' mapping='logical'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;attribute name='accountid' /&gt;
    &lt;attribute name='accountid' rowaggregate='CountChildren' alias='AccountChildren'/&gt;
    &lt;filter type='and'&gt;
      &lt;condition attribute='accountid' operator='under' value='{0}' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>Using DateTime Operators with the SSIS Dynamics CRM / Dataverse read task</h3>
<p>This example shows how to write FetchXML query to get all tickets which are created 30 mins before.</p>
<p>Other similar operators are<br />
olderthan-x-hours<br />
olderthan-x-days<br />
olderthan-x-weeks<br />
olderthan-x-months<br />
olderthan-x-years</p>
<p>For a list of supported DateTime operators<br />
<a href="https://msdn.microsoft.com/en-us/library/gg334216.aspx">https://msdn.microsoft.com/en-us/library/gg334216.aspx</a></p>
<p>For a list of all supported operators check below XSD and search for name=&#8221;operator&#8221;<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p>
<p>To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch&gt;
  &lt;entity name='incident'&gt;
    &lt;attribute name='title' /&gt;
    &lt;attribute name='ticketnumber' /&gt;
    &lt;attribute name='createdon' /&gt;
    &lt;attribute name='incidentid' /&gt;
    &lt;filter type='and'&gt;
      &lt;condition attribute='createdon' operator='olderthan-x-minutes' value='30' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h3>Query &#8211; All activities (sort, outer join, alias) with the SSIS Dynamics CRM / Dataverse read task</h3>
<p>This example shows how to get all activities performed on lead or contact. It shows how to get attributes from lead and contact by using OUTER JOIN.</p>
<p>This FetchXML is the equivalent of below SQL</p><pre class="crayon-plain-tag">SELECT a.*
, l.firstname as lead_name,l.emailadddress1 as lead_email1
, c.firstname as contact_name
FROM activitypointer a
LEFT OUTER JONI lead l ON a.regardingobjectid=l.leadid
LEFT OUTER JONI lead c ON a.regardingobjectid=c.contactid
ORDER BY a.createdon DESC</pre><p>
To build custom FetxhXML<br />
1. Login to your Dynamics CRM / Dataverse Portal<br />
2. Click on Advanced Find icon (Found next to the search textbox)<br />
3. Once done building query, Click on Download FetchXML icon. Copy that XML into Query editor of Dynamics CRM / Dataverse Source.</p>
<p>For more information about FetchXML query syntax check below links :<br />
<a href="https://msdn.microsoft.com/en-us/library/gg328117.aspx">https://msdn.microsoft.com/en-us/library/gg328117.aspx</a><br />
<a href="https://msdn.microsoft.com/en-us/library/gg328332.aspx">https://msdn.microsoft.com/en-us/library/gg328332.aspx</a></p>
<p>For complete syntax and validation rule for FetchXML check below XSD<br />
<a href="https://msdn.microsoft.com/en-us/library/gg309405.aspx">https://msdn.microsoft.com/en-us/library/gg309405.aspx</a></p><pre class="crayon-plain-tag">&lt;fetch version='1.0' mapping='logical'&gt;
	&lt;entity name='activitypointer'&gt;
		&lt;attribute name='subject' /&gt;
		&lt;attribute name='ownerid' /&gt;
		&lt;attribute name='regardingobjectid' /&gt;
		&lt;attribute name='activitytypecode' /&gt;
		&lt;attribute name='scheduledstart' /&gt;
		&lt;attribute name='scheduledend' /&gt;
		&lt;attribute name='instancetypecode' /&gt;
		&lt;attribute name='community' /&gt;
		&lt;attribute name='actualend' /&gt;
		&lt;attribute name='createdon' /&gt;
		
		&lt;link-entity name='lead' from='leadid' to='regardingobjectid' link-type='outer' alias='l'&gt;
			&lt;attribute name='firstname' alias='lead_name' /&gt;
			&lt;attribute name='emailaddress1' alias='lead_email1' /&gt;
			&lt;attribute name='companyname' alias='lead_company' /&gt;
		&lt;/link-entity&gt;  
		
		&lt;link-entity name='contact' from='contactid' to='regardingobjectid' link-type='outer' alias='c'&gt;
			&lt;attribute name='firstname' alias='contact_name' /&gt;
		&lt;/link-entity&gt;  

		&lt;order attribute='createdon' descending='true' /&gt;
	&lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h2>How to use SSIS variables with Fetch XML in SSIS for SSIS Dynamics</h2>
<h2>CRM read</h2>
<p>You can include variables in an XML fetch.</p>
<ol>
<li>
        First, create your variable in the SSDT. Go to SSIS and Variables and create your variable:</p>
<p>        <div id="attachment_3514" style="width: 762px" class="wp-caption aligncenter"><a href="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-variable-value.jpg"><img loading="lazy" decoding="async" aria-describedby="caption-attachment-3514" class="size-full wp-image-3514" src="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-variable-value.jpg" alt="ssis-variable-value" width="752" height="113" srcset="https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-variable-value.jpg 752w, https://zappysys.com/blog/wp-content/uploads/2018/05/ssis-variable-value-300x45.jpg 300w" sizes="(max-width: 752px) 100vw, 752px" /></a><p id="caption-attachment-3514" class="wp-caption-text">SSIS variable value</p></div>
    </li>
</ol>
<p>In addition, create your fetch, include the variable in the XM ({{User::value}}):</p><pre class="crayon-plain-tag">&lt;fetch mapping='logical' version='1.0'&gt;
  &lt;entity name='account'&gt;
    &lt;attribute name='name' /&gt;
    &lt;filter&gt;
      &lt;condition attribute='revenue' operator='eq' value='{{User::value}}' /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;</pre><p>
<h2>Conclusion about the SSIS Dynamics CRM / Dataverse read task</h2>
<p>To conclude, we can say that the ZS Dynamic CRM source is a great tool to get data from Microsoft CRM Dynamics and export any other destination format. In this article, we learn how to create queries to CRM Dynamics using fetch data. We used several examples to query data. We also learned to use SSIS variables in our queries and how to export the data from Dynamics CRM / Dataverse to SQL Server. <a href="https://zappysys.com/products/ssis-powerpack/download/" target="_blank" rel="noopener">Download SSIS PowerPack</a> to explore Dynamics CRM / Dataverse integration possibilities in SSIS.</p>
<h2>References about SSIS Dynamics CRM / Dataverse read</h2>
<ul>
<li><a href="https://www.microsoft.com/en-us/dynamics365/what-is-crm">What is CRM?</a></li>
<li><a href="https://zappysys.com/products/ssis-powerpack/ssis-dynamics-crm-source-connector/">SSIS Dynamics CRM / Dataverse Source Connector (Dynamics 365 / On-Premises CRM)</a></li>
</ul>
<p>The post <a href="https://zappysys.com/blog/ssis-dynamics-crm-read-import-crm-365-onpremises/">SSIS Dynamics CRM / Dataverse &#8211; Read / Import data into SQL Server</a> appeared first on <a href="https://zappysys.com/blog">ZappySys Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
