<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[KingswaySoft - Alexander Development]]></title><description><![CDATA[KingswaySoft - Alexander Development]]></description><link>https://alexanderdevelopment.net/</link><image><url>https://alexanderdevelopment.net/favicon.png</url><title>KingswaySoft - Alexander Development</title><link>https://alexanderdevelopment.net/</link></image><generator>Ghost 1.20</generator><lastBuildDate>Fri, 24 Apr 2026 14:23:42 GMT</lastBuildDate><atom:link href="https://alexanderdevelopment.net/tag/kingswaysoft/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Recently I was asked to set up a process to automatically disable or re-enable Dynamics 365 Customer Engagement users depending on some external data. This ended up being ridiculously easy to do with SSIS and KingswaySoft's <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365">Dynamics 365 Integration Toolkit</a>. Let me show you how it works.</p>
<p>In Dynamics 365</p></div>]]></description><link>https://alexanderdevelopment.net/post/2018/02/08/disable-enable-dynamics-365-ce-users-with-ssis-kingswaysoft/</link><guid isPermaLink="false">5a7c568fc86c8900016cf372</guid><category><![CDATA[Microsoft Dynamics CRM]]></category><category><![CDATA[Dynamics 365]]></category><category><![CDATA[integration]]></category><category><![CDATA[KingswaySoft]]></category><category><![CDATA[SSIS]]></category><dc:creator><![CDATA[Lucas Alexander]]></dc:creator><pubDate>Thu, 08 Feb 2018 19:01:01 GMT</pubDate><media:content url="https://alexanderdevelopment.net/content/images/2018/02/02_query_users-1.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://alexanderdevelopment.net/content/images/2018/02/02_query_users-1.png" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"><p>Recently I was asked to set up a process to automatically disable or re-enable Dynamics 365 Customer Engagement users depending on some external data. This ended up being ridiculously easy to do with SSIS and KingswaySoft's <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365">Dynamics 365 Integration Toolkit</a>. Let me show you how it works.</p>
<p>In Dynamics 365 CE, you can disable or enable a user record just by setting the value of its &quot;isdisabled&quot; attribute to true or false, so both my disable user data flow and re-enable user data flow do roughly the same thing.</p>
<ol>
<li>Get a list of Dynamics 365 user records to update.</li>
<li>Add a derived column to hold the value to use for updating isdisabled on the user records.</li>
<li>Update the user records.</li>
</ol>
<h4 id="thedisableuserspackage">The disable users package</h4>
<p>Here's a screenshot of a sample disable users data flow.<br>
<img src="https://alexanderdevelopment.net/content/images/2018/02/01_disable_user_flow.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
<p>Let's take a closer look at each step.</p>
<ol>
<li>Query users using FetchXML. <img src="https://alexanderdevelopment.net/content/images/2018/02/02_query_users.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></li>
<li>Add a derived column named &quot;isdisabled&quot; and set its value to 1. <img src="https://alexanderdevelopment.net/content/images/2018/02/03_isdisabled_column.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></li>
<li>Update the users. <img src="https://alexanderdevelopment.net/content/images/2018/02/04_update_users.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></li>
</ol>
<p>Enabling the users works exactly the same way, except the value of the &quot;isdisabled&quot; column should be 0 instead of 1, so I won't show the screenshots for that package.</p>
<h4 id="disableuserdemo">Disable user demo</h4>
<p>In my Dynamics 365 online instance, I have an active user named &quot;Angus Alexander&quot; who I want to disable. <img src="https://alexanderdevelopment.net/content/images/2018/02/05_enabled_users.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
<p>When I run the disable users package with the query from above (<code>&lt;condition attribute=&quot;firstname&quot; operator=&quot;eq&quot; value=&quot;angus&quot; /&gt;</code>) in Visual Studio, I see success on every step. <img src="https://alexanderdevelopment.net/content/images/2018/02/06_package_run.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
<p>I check back in Dynamics 365 to see Angus Alexander is no longer an enabled user. <img src="https://alexanderdevelopment.net/content/images/2018/02/07_enabled_users.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
<p>Instead Angus shows up as a disabled user. <img src="https://alexanderdevelopment.net/content/images/2018/02/08_disabled_users.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
<p>Now when Angus tries to access Dynamics 365, he sees that his account has been disabled. <img src="https://alexanderdevelopment.net/content/images/2018/02/09_disabled_message.png#img-thumbnail" alt="Disable and enable Dynamics 365 CE users with SSIS & KingswaySoft"></p>
</div>]]></content:encoded></item><item><title><![CDATA[Another approach to complex Dynamics 365 text interfaces using KingswaySoft and XSLT]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Last week I posted an approach for <a href="https://alexanderdevelopment.net/post/2017/06/15/generating-complex-text-files-with-kingswaysoft-and-xslt/">generating complex text files from Dynamics 365 with KingswaySoft and XSLT</a> that uses a custom script component to apply an XSL transformation to an XML document generated with the the <a href="https://www.kingswaysoft.com/products/ssis-productivity-pack/help-manual/data-pack-and-unpack/xml-merge">SSIS XML merge component</a> from the <a href="http://www.kingswaysoft.com/products/ssis-productivity-pack">KingswaySoft SSIS productivity pack</a>.</p>
<p>After I shared</p></div>]]></description><link>https://alexanderdevelopment.net/post/2017/06/23/another-approach-to-complex-dynamics-365-text-interfaces-using-kingswaysoft-and-xslt/</link><guid isPermaLink="false">5a5837246636a30001b978b6</guid><category><![CDATA[Microsoft Dynamics CRM]]></category><category><![CDATA[Dynamics 365]]></category><category><![CDATA[integration]]></category><category><![CDATA[SSIS]]></category><category><![CDATA[KingswaySoft]]></category><dc:creator><![CDATA[Lucas Alexander]]></dc:creator><pubDate>Fri, 23 Jun 2017 17:30:00 GMT</pubDate><media:content url="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-23_11-55-17.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-23_11-55-17.png" alt="Another approach to complex Dynamics 365 text interfaces using KingswaySoft and XSLT"><p>Last week I posted an approach for <a href="https://alexanderdevelopment.net/post/2017/06/15/generating-complex-text-files-with-kingswaysoft-and-xslt/">generating complex text files from Dynamics 365 with KingswaySoft and XSLT</a> that uses a custom script component to apply an XSL transformation to an XML document generated with the the <a href="https://www.kingswaysoft.com/products/ssis-productivity-pack/help-manual/data-pack-and-unpack/xml-merge">SSIS XML merge component</a> from the <a href="http://www.kingswaysoft.com/products/ssis-productivity-pack">KingswaySoft SSIS productivity pack</a>.</p>
<p>After I shared that post, <a href="https://twitter.com/danielcai">Daniel Cai</a> at KingswaySoft told me the <a href="https://www.kingswaysoft.com/products/ssis-productivity-pack/help-manual/premium-data-flow-components/premium-derived-column">premium derived column</a> component in the SSIS productivity pack can also be used to apply the XSL transformation. In today's post I will show how I reworked my earlier example to use that approach for a no-code solution.</p>
<p>Assuming you have XML generated like I showed in my previous post, switching from the script component to the premium derived column for the XSLT step is easy. The premium derived column has a few different XML functions that you can see in the screenshot below:<br>
<img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-23_12-02-40.png#img-thumbnail" alt="Another approach to complex Dynamics 365 text interfaces using KingswaySoft and XSLT"></p>
<p>You can pass in XSLT directly to the XslTransform functions, but I've decided to use a variable instead to make this easier to manage. Note that when you set the derived column expression, the length will automatically be set to a length that's based on the length of your XSL. This is almost certainly going to be too short, which will cause your package to fail, so make sure you manually set a more reasonable value, which is 4000 in my example.</p>
<p>As far as the variable, it's just a string variable, but I'd advise you not to set the string value directly. If you do that, getting the formatting right with the line breaks can be tricky. If you set the variable via an expression, getting the formatting right is much easier.<br>
<img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-23_12-08-43.png#img-thumbnail" alt="Another approach to complex Dynamics 365 text interfaces using KingswaySoft and XSLT"></p>
</div>]]></content:encoded></item><item><title><![CDATA[Generating complex text files from Dynamics 365 with KingswaySoft and XSLT]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Recently I needed to build an SSIS package that would generate a delimited text file with multiple sets of related (but different entity) Dynamics 365 records combined in a single grouping. Each record would be on a separate row (with different formats for each record type), and each grouping of</p></div>]]></description><link>https://alexanderdevelopment.net/post/2017/06/15/generating-complex-text-files-with-kingswaysoft-and-xslt/</link><guid isPermaLink="false">5a5837246636a30001b978b0</guid><category><![CDATA[Microsoft Dynamics CRM]]></category><category><![CDATA[Dynamics 365]]></category><category><![CDATA[integration]]></category><category><![CDATA[SSIS]]></category><category><![CDATA[KingswaySoft]]></category><dc:creator><![CDATA[Lucas Alexander]]></dc:creator><pubDate>Thu, 15 Jun 2017 12:00:00 GMT</pubDate><media:content url="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-14_10-13-09.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-14_10-13-09.png" alt="Generating complex text files from Dynamics 365 with KingswaySoft and XSLT"><p>Recently I needed to build an SSIS package that would generate a delimited text file with multiple sets of related (but different entity) Dynamics 365 records combined in a single grouping. Each record would be on a separate row (with different formats for each record type), and each grouping of related records would have its own header and trailer rows. To give you a better idea of what that would look like, consider this example format for listing accounts and related contacts:</p>
<pre><code>HEADER  {accountid}~
ACCOUNT {account name}|{account city}|{account state}~
CONTACT {contact id}|{contact name}|{contact phone number}~
TRAILER {accountid}|{number of contacts}~
</code></pre>
<p>A data export from Dynamics 365's sample data would look like this:</p>
<pre><code>HEADER  2023a3fa-5d74-e611-944a-08002751dfcb~
ACCOUNT A. Datum Corporation (sample)|Redmond|WA~
CONTACT 8623a3fa-5d74-e611-944a-08002751dfcb|Rene Valdes (sample)|555-0108~
CONTACT 8c23a3fa-5d74-e611-944a-08002751dfcb|Susan Burk (sample)|555-0111~
TRAILER 2023a3fa-5d74-e611-944a-08002751dfcb|2~
HEADER  1423a3fa-5d74-e611-944a-08002751dfcb~
ACCOUNT Adventure Works (sample)|Santa Cruz|TX~
CONTACT 7a23a3fa-5d74-e611-944a-08002751dfcb|Nancy Anderson (sample)|555-0102~
TRAILER 1423a3fa-5d74-e611-944a-08002751dfcb|1~
</code></pre>
<p>I considered using <a href="https://docs.microsoft.com/en-us/sql/integration-services/data-flow/transformations/script-component">SSIS script components</a> to construct the text output using .Net's normal string manipulation capabilities, but that seemed like it would be a lot of work, and if the output format ever needed to change, I'd need to make changes to my code to handle it. After some pondering, I realized that if I could generate an XML document from the Dynamics 365 records, I would be able to use <a href="https://en.wikipedia.org/wiki/XSLT">XSLT</a> to transform it to any kind of text output. Additionally, if the output format ever needed to change, I would only have to update the XSLT stylesheet.</p>
<p>This approach requires three steps:</p>
<ol>
<li>Query the different data sets.</li>
<li>Merge them into a single XML document.</li>
<li>Convert XML into output format with XSLT.</li>
</ol>
<h4 id="queryingthedata">Querying the data</h4>
<p>I'm using the <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365">KingswaySoft SSIS integration toolkit</a> to query the Dynamics 365 data. I have a query for active accounts and a separate query for active contacts. Here's the FetchXML for each query:</p>
<pre><code>&lt;fetch version=&quot;1.0&quot; output-format=&quot;xml-platform&quot; mapping=&quot;logical&quot; distinct=&quot;false&quot;&gt;
  &lt;entity name=&quot;account&quot;&gt;
    &lt;attribute name=&quot;name&quot; /&gt;
    &lt;attribute name=&quot;address1_city&quot; /&gt;
    &lt;attribute name=&quot;primarycontactid&quot; /&gt;
    &lt;attribute name=&quot;telephone1&quot; /&gt;
    &lt;attribute name=&quot;accountid&quot; /&gt;
    &lt;attribute name=&quot;address1_stateorprovince&quot; /&gt;
    &lt;order attribute=&quot;name&quot; descending=&quot;false&quot; /&gt;
    &lt;filter type=&quot;and&quot;&gt;
      &lt;condition attribute=&quot;statecode&quot; operator=&quot;eq&quot; value=&quot;0&quot; /&gt;
    &lt;/filter&gt;
    &lt;link-entity name=&quot;contact&quot; from=&quot;contactid&quot; to=&quot;primarycontactid&quot; visible=&quot;false&quot; link-type=&quot;outer&quot; alias=&quot;accountprimarycontactidcontactcontactid&quot;&gt;
      &lt;attribute name=&quot;emailaddress1&quot; /&gt;
    &lt;/link-entity&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;

&lt;fetch version=&quot;1.0&quot; output-format=&quot;xml-platform&quot; mapping=&quot;logical&quot; distinct=&quot;false&quot;&gt;
  &lt;entity name=&quot;contact&quot;&gt;
    &lt;attribute name=&quot;fullname&quot; /&gt;
    &lt;attribute name=&quot;parentcustomerid&quot; /&gt;
    &lt;attribute name=&quot;telephone1&quot; /&gt;
    &lt;attribute name=&quot;emailaddress1&quot; /&gt;
    &lt;attribute name=&quot;contactid&quot; /&gt;
    &lt;order attribute=&quot;fullname&quot; descending=&quot;false&quot; /&gt;
    &lt;filter type=&quot;and&quot;&gt;
      &lt;condition attribute=&quot;statecode&quot; operator=&quot;eq&quot; value=&quot;0&quot; /&gt;
      &lt;condition attribute=&quot;parentcustomerid&quot; operator=&quot;not-null&quot; /&gt;
    &lt;/filter&gt;
  &lt;/entity&gt;
&lt;/fetch&gt;
</code></pre>
<h4 id="generatingthexml">Generating the XML</h4>
<p>You could generate the XML document using a script component in your data flow, but I'm using the <a href="https://www.kingswaysoft.com/products/ssis-productivity-pack/help-manual/data-pack-and-unpack/xml-merge">SSIS XML merge component</a> from the <a href="http://www.kingswaysoft.com/products/ssis-productivity-pack">KingswaySoft SSIS productivity pack</a>. Note, this component is not included with the Dynamics 365 SSIS integration toolkit, so you will need an additional license (or the KingswaySoft ultimate edition license) to use it.</p>
<p>The XML merge component lets you specify the relationships between the different data sets.<br>
<img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-14_09-53-54.png#img-thumbnail" alt="Generating complex text files from Dynamics 365 with KingswaySoft and XSLT"></p>
<p>And then you can specify the output format.<br>
<img src="https://alexanderdevelopment.net/content/images/2017/06/devenv_2017-06-14_09-54-00.png#img-thumbnail" alt="Generating complex text files from Dynamics 365 with KingswaySoft and XSLT"></p>
<p>The output is a DT_NTEXT column called &quot;MergedXml,&quot; but you can change the name.</p>
<h4 id="convertingthexml">Converting the XML</h4>
<p>SSIS has an <a href="https://docs.microsoft.com/en-us/sql/integration-services/control-flow/xml-task">XML task component</a> you can use in the package control flow to transform XML with XSLT, but I had some problems getting that to work just the way I wanted. Instead I decided to perform the transformation in a script component inside my data flow. Here's the code from the script component to do that:</p>
<pre><code>public override void Input0_ProcessInputRow(Input0Buffer Row)
{
	//build the xsl
	XslCompiledTransform xslt = new XslCompiledTransform();
	string xsl = &quot;&lt;xsl:stylesheet version=\&quot;1.0\&quot; xmlns:xsl=\&quot;http://www.w3.org/1999/XSL/Transform\&quot;&gt;&quot; +
		&quot;&lt;xsl:template match=\&quot;/\&quot;&gt;&quot; +
		&quot;&lt;xsl:for-each select=\&quot;accounts/account\&quot;&gt;&quot; +
		&quot;\n&quot; +
		&quot;HEADER  &lt;xsl:value-of select=\&quot;accountid\&quot;/&gt;~\n&quot; +
		&quot;ACCOUNT &lt;xsl:value-of select=\&quot;name\&quot;/&gt;|&lt;xsl:value-of select=\&quot;address1_city\&quot;/&gt;|&lt;xsl:value-of select=\&quot;address1_stateorprovince\&quot;/&gt;~\n&quot; +
		&quot;&lt;xsl:for-each select=\&quot;contacts/contact\&quot;&gt;&quot; +
		&quot;CONTACT &lt;xsl:value-of select=\&quot;contactid\&quot;/&gt;|&lt;xsl:value-of select=\&quot;fullname\&quot;/&gt;|&lt;xsl:value-of select=\&quot;telephone1\&quot;/&gt;~\n&quot; +
		&quot;&lt;/xsl:for-each&gt;&quot; +
		&quot;TRAILER &lt;xsl:value-of select=\&quot;accountid\&quot;/&gt;|&lt;xsl:value-of select=\&quot;count(contacts/contact)\&quot; /&gt;~&quot; +
		&quot;&lt;/xsl:for-each&gt;&quot; +
		&quot;&lt;/xsl:template&gt;&quot; +
		&quot;&lt;/xsl:stylesheet&gt;&quot;;
	System.Text.UnicodeEncoding myEncoder = new System.Text.UnicodeEncoding();
	Byte[] bytes = myEncoder.GetBytes(xsl);
	MemoryStream xslms = new MemoryStream(bytes);

	//load it
	xslt.Load(XmlReader.Create(xslms));

	//transform the xml using the xslt
	string outputtext = &quot;&quot;;
	string rawxml = BlobColumnToString(Row.MergedXml);
	using (StringReader sr = new StringReader(rawxml))
	{
		using (XmlReader xr = XmlReader.Create(sr))
		{
			using (StringWriter sw = new StringWriter())
			{
				xslt.Transform(xr, null, sw);
				outputtext = sw.ToString();
			}
		}
	}

	//to remove the xml document declaration in the first line, we need to split the output into an array of lines first
	string[] lines = outputtext.Split(new string[] { &quot;\r\n&quot;, &quot;\n&quot; }, StringSplitOptions.None);

	//join all the lines except the first one back together
	string outputlines = string.Join(&quot;\n&quot;, lines, 1, lines.Length - 1); //leave out the first line (xml declaration)

	//add an output row
	Output0Buffer.AddRow();

	//set the value of the output row column to the rejoined output lines value
	Output0Buffer.TransformOutput.AddBlobData(System.Text.Encoding.UTF8.GetBytes(outputlines));
}

/// &lt;summary&gt;
/// converts blob column data to a string - from https://stackoverflow.com/a/14253887
/// &lt;/summary&gt;
string BlobColumnToString(Microsoft.SqlServer.Dts.Pipeline.BlobColumn blobColumn)
{
	if (blobColumn.IsNull)
		return string.Empty;

	var blobLength = Convert.ToInt32(blobColumn.Length);
	var blobData = blobColumn.GetBlobData(0, blobLength);
	var stringData = System.Text.Encoding.Unicode.GetString(blobData);

	return stringData;
}
</code></pre>
<p>A few notes:</p>
<ol>
<li>You will need to add using directives for these namespaces to your script: System.Xml, System.Xml.Xsl, System.IO.</li>
<li>The BlobColumnToString helper method is necessary to read the contents of the MergedXml column into a string variable.</li>
<li>Ideally you would store the XSL outside the script code so that it's easier to manage.</li>
<li>When you transform the XML, the first line of the output will be an XML document declaration. I am removing that first line of the output with the code starting at line 44 in my sample above.</li>
</ol>
</div>]]></content:encoded></item><item><title><![CDATA[Real-time Dynamics 365 data integrations with SSIS + KingswaySoft]]></title><description><![CDATA[<div class="kg-card-markdown"><p>I'm a big fan of KingswaySoft's <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365">Dynamics 365 SSIS integration toolkit</a> for moving data between Dynamics 365 and other systems. Because the integrations are run in SSIS packages, there's a lot of power and flexibility, and you can use SQL Server Agent to orchestrate your integration jobs. This is great</p></div>]]></description><link>https://alexanderdevelopment.net/post/2017/06/13/real-time-dynamics-365-data-integrations-with-ssis-kingswaysoft/</link><guid isPermaLink="false">5a5837246636a30001b978aa</guid><category><![CDATA[Microsoft Dynamics CRM]]></category><category><![CDATA[Dynamics 365]]></category><category><![CDATA[integration]]></category><category><![CDATA[SSIS]]></category><category><![CDATA[KingswaySoft]]></category><dc:creator><![CDATA[Lucas Alexander]]></dc:creator><pubDate>Tue, 13 Jun 2017 12:00:00 GMT</pubDate><content:encoded><![CDATA[<div class="kg-card-markdown"><p>I'm a big fan of KingswaySoft's <a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-365">Dynamics 365 SSIS integration toolkit</a> for moving data between Dynamics 365 and other systems. Because the integrations are run in SSIS packages, there's a lot of power and flexibility, and you can use SQL Server Agent to orchestrate your integration jobs. This is great for scheduled jobs, but what do you do if you need to trigger a job based on activity in Dynamics 365? In today's post, I will describe an approach that you can use to solve this problem.</p>
<p>Starting with SQL Server 2012, the SSIS catalog database includes a set of stored procedures that can be used to execute SSIS packages from T-SQL. Here's an example of how to call them:</p>
<pre><code>--create variable to hold execution id
Declare @execution_id bigint  

--create execution to run later
EXEC [SSISDB].[catalog].[create_execution] @package_name=N'MyPackage.dtsx', @execution_id=@execution_id OUTPUT, @folder_name=N'MyPackageFolder', @project_name=N'MyPackageProject', @use32bitruntime=False, @reference_id=Null  

--populate any input parameters
DECLARE @var0 sql_variant = N'Some input parameter value'  
EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=30, @parameter_name=N'Parameter1', @parameter_value=@var0  

--execute the package
EXEC [SSISDB].[catalog].[start_execution] @execution_id  
GO  
</code></pre>
<p>I am using a Dynamics 365 plug-in to execute the SSIS packages, but you could just as easily use a custom workflow activity. One other advantage to using the plug-in is that I can access the pre/post-operation images and parse them for data to pass to my SSIS package.</p>
<p>I also created a wrapper stored procedure in a separate database to run the T-SQL above just to streamline the code in my plug-in.</p>
<p>There are a couple of issues with this approach:</p>
<ol>
<li>Calling SQL stored procedures is not supported in an isolated plug-in, so you can't use this approach in a Dynamics 365 online deployment, and your infrastructure team will need to be OK with running plug-ins outside the sandbox.</li>
<li>Calling operations in the SSIS catalog database requires Windows authentication instead of SQL Server authentication, but you can't supply specific Windows credentials from a plug-in when you execute the SQL stored procedure (you can only use integrated security). The only way I could make this work was to grant permission for the service account running CRM (NT AUTHORITY\NETWORK SERVICE on my development VM) rights to execute the wrapper stored procedure and to access the SSIS catalog database.</li>
</ol>
<p>If either of these issues are a showstopper for you, an alternate approach would be to build an intermediate web service that can call the SQL stored procedure to execute the SSIS packages. You can then call this web service from a sandboxed plug-in or custom workflow activity.</p>
<p>What do you think about this approach? Have you done something different to solve a similar integration challenge? Please let us know in the comments!</p>
</div>]]></content:encoded></item><item><title><![CDATA[SSIS package for moving access team templates with KingswaySoft]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Last year Ben Hosking said there was <a href="https://crmbusiness.wordpress.com/2014/12/01/crm-2013-why-are-access-teams-marooned/">no way to move access teams between Dynamics CRM organizations</a>, so I created <a href="http://alexanderdevelopment.net/post/2014/12/13/console-application-for-moving-dynamics-crm-access-team-templates/#comment-2308742658">a tool to do that</a>. Last month Tanguy Touzard said I should turn my console application into an <a href="http://disq.us/8qdywm">XrmToolBox plugin</a>, so <a href="http://alexanderdevelopment.net/post/2015/10/20/xrmtoolbox-plugin-for-moving-access-team-templates/">I did</a>. Soon after that <a href="https://twitter.com/danielcai">Daniel Cai</a> said I</p></div>]]></description><link>https://alexanderdevelopment.net/post/2015/11/01/ssis-package-for-moving-access-team-templates-with-kingswaysoft/</link><guid isPermaLink="false">5a5837236636a30001b977d7</guid><category><![CDATA[Microsoft Dynamics CRM]]></category><category><![CDATA[CRM 2015]]></category><category><![CDATA[SSIS]]></category><category><![CDATA[KingswaySoft]]></category><dc:creator><![CDATA[Lucas Alexander]]></dc:creator><pubDate>Mon, 02 Nov 2015 03:13:14 GMT</pubDate><media:content url="https://alexanderdevelopment.net/content/images/2015/11/source-1.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://alexanderdevelopment.net/content/images/2015/11/source-1.png" alt="SSIS package for moving access team templates with KingswaySoft"><p>Last year Ben Hosking said there was <a href="https://crmbusiness.wordpress.com/2014/12/01/crm-2013-why-are-access-teams-marooned/">no way to move access teams between Dynamics CRM organizations</a>, so I created <a href="http://alexanderdevelopment.net/post/2014/12/13/console-application-for-moving-dynamics-crm-access-team-templates/#comment-2308742658">a tool to do that</a>. Last month Tanguy Touzard said I should turn my console application into an <a href="http://disq.us/8qdywm">XrmToolBox plugin</a>, so <a href="http://alexanderdevelopment.net/post/2015/10/20/xrmtoolbox-plugin-for-moving-access-team-templates/">I did</a>. Soon after that <a href="https://twitter.com/danielcai">Daniel Cai</a> said I should make something with the KingswaySoft SSIS Integration Toolkit, so I've now written a version of my access team template mover as an SSIS package.</p>
<h4 id="thelogic">The logic</h4>
<p><a href="http://www.kingswaysoft.com/products/ssis-integration-toolkit-for-microsoft-dynamics-crm">KingswaySoft's Dynamics CRM SSIS adapter</a> makes basic CRM retrieves and inserts easy, so I could have written a simple package to do a full copy of access team templates from a source to a target in about 10 minutes, but I wanted to include the same functionality as my XrmToolBox plugin to enable access teams on the relevant entities in the target organization if desired.</p>
<p>Unfortunately the KingswaySoft adapter doesn't make working with Dynamics CRM metadata easy, so I had to use an SSIS transformation script task to check whether access teams are enabled for a particular entity and enable them.</p>
<p>After the transformation script task checks whether access teams are enabled for the entities in the target organization and (optionally) enables them, a conditional split transformation passes teamtemplate records for entities that are enabled for access teams to a Dynamics CRM destination task to create or update the teamtemplate records in the target organization.</p>
<p>Here's what the data flow task looks like with all the components on the canvas:<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/dataflow.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<p>Let's take a closer look at all of them.</p>
<h4 id="theretrievetask">The retrieve task</h4>
<p>The data flow starts with a Dynamics CRM source task to retrieve teamtemplate records from the source organization. Although you could use an entity source type, I use FetchXML to offer greater flexibility. For example it would be possible to only sync access teams that have names starting with a particular string value.<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/source.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<h4 id="thetransformationscripttask">The transformation script task</h4>
<p>KingswaySoft's Dynamics CRM adapter supports the use of its connection managers in SSIS script tasks, but there are a few extra steps you need to take that are described in this <a href="http://www.kingswaysoft.com/blog/2013/06/24/Writing-Script-Component-or-Script-Task-using-CRM-Connection-Manager">blog post</a>.</p>
<p>Because SSIS processes the data in a row-by-row fashion, I needed to use slightly different logic in the SSIS package to check for whether entities have access teams enabled and then enable them. In the PreExecute method, the package establishes source/target connections and then retrieves metadata for all the entities in the target system. Next it stores the objecttypecode values for each enabled entity in a list of strings. This actually took me a while to get right, because KingswaySoft returns an entity's logical name as the objecttypecode attribute instead of the actual numeric CRM objecttypecode value.</p>
<p>As the transformation script task loops through each row, it does the following:</p>
<ol>
<li>Check whether the entity is enabled for access teams in the target. If so, set the value of an "enabled" output column to true. 
</li><li>If the entity isn't enabled for access teams in the target organization:<ol>
<li>If a package parameter to automatically enable access teams is set to true, update the entity in the target organization to enable access teams and set the "enabled" output column to true. Also add the entity's logical name to the list of enabled entities so the script won't unnecessarily update the target system if it encounters another teamtemplate record for the same entity later.
</li><li>Otherwise, set the "enabled" output column to false.
</li></ol>
</li></ol>
<h4 id="theconditionalsplit">The conditional split</h4>
<p>The conditional split transformation has two outputs - one for rows with the enabled column set to true and one for rows with the enabled column set to false. My version of the package doesn't actually do anything with the &quot;disabled&quot; output, but you could do something with those rows if you wanted.<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/split.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<h4 id="theupsert">The upsert</h4>
<p>The package creates or updates teamtemplate records in the target organization with a Dynamics CRM destination upsert task.<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/upsert-1.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<p>All the columns are mapped except for the createdby and modifiedby attributes.<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/upsert-2.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<h4 id="packageparameters">Package parameters</h4>
<p>As I mentioned earlier, the package supports optionally enabling entities for access teams in the target system. That's done via a package parameter called &quot;enableTargetAccessTeams.&quot; The package also has additional parameters for setting the source and target connection strings and passwords.<br>
<img src="https://alexanderdevelopment.net/content/images/2015/11/parameters.png#img-thumbnail" alt="SSIS package for moving access team templates with KingswaySoft"></p>
<h4 id="wrappingup">Wrapping up</h4>
<p>You can get the package from my GitHub repository <a href="https://github.com/lucasalexander/Crm-Sample-Code/tree/master/SSIS/ReferenceDataMover">here</a>. I hope to add more packages to this solution for synchronizing other reference data records like business units, teams and queues in the near future. Stay tuned!</p>
</div>]]></content:encoded></item></channel></rss>