Biml, Microsoft Technologies, SSIS

Biml for a Task Factory Dynamics CRM Source Component

I recently worked on a project where a client wanted to use Biml to create SSIS packages to stage data from Dynamics 365 CRM. My first attempt using a script component had an error, which I think is related to a bug in the Biml engine with how it currently generates script components, so I had to find a different way to accomplish my goal. (If you have run into this issue with Biml, please comment so I know it’s not just me! I have yet to get Varigence to confirm it.) This client owned the Pragmatic Works Task Factory, so we used the Dynamics CRM source to retrieve data.

I was ultimately creating a bunch of packages that looked like the below.

There are two pieces to using the Task Factory Dynamics CRM Source: the source component and the connection manager. The code for both is below.

Things to note for the source component:

  •  This is pulling data for an entity in Dynamics 365. If you were to populate this by hand, the Task Factory UI would ask you which entity. There are several entities that are visible, but do not allow you to retrieve the data. You can find a list of internal entities here.  You won’t want to stage data from those tables. I generated all of my packages at once with Biml, using a Blacklist to exclude the internal entities.
  • The entity name that should be the value on line 21 is the entity logical name.
  • I’m iterating through columns in tables in a separate file and holding them in memory, hence the references to Table.columns. You’ll need to write some code to get the entity metadata to feed that, or find another way to provide the table names and column names and data types.
  • You must set the ErrorRowDisposition and TruncateRowDisposition to “NotUsed” as I did on line 10 for each column or your package will not work.
  • In OutputColumns and ExternalColumns collections, I just have if statements to check data types. There may be a more elegant way to do this, but this worked for me and I went with it. Feel free to leave suggestions in the comments if you have a better idea.
  • The Connection element on line 145 should keep the name “DYNAMICSCONNECTION”. If you change it, the connection won’t work. In my actual project, my connection manager is in a separate file and is named “TF_DynamicsCRM”. You can set the ConnectionName property to whatever you want, as long as it matches your connection definition (Line 153 in the gist).

Things to note for the Connection Manager:

  • I tried reverse engineering the connection manager in Biml Studio, and that got me close, but it didn’t get the ObjectData property quite right. I ended up having to create one manually, view the code for it in SSDT, and copy it into my Biml file. I have my packages and project set to EncryptSensitiveWithPassword, which is why you see the p4:Salt value on line 158. Your connection manager will have different values for lines 158, 159, and 160. If you set your project to EncryptSensitiveWithPassword, this value will stay consistent across developers. But if you use EncryptSensitiveWithUserKey, the value may change, which will be fun for regenerating with Biml. So make sure you plan for that if you have multiple developers or multiple computers on which you are working.
  • This connection manager is set to connect to Dynamics 365, hence the If you have an on-prem or hosted environment that isn’t 365, you’ll have to find the correct ServerHost value and put it in line 165.

I hope that helps someone looking to generate the Task Factory Dynamics Source with Biml.

8 thoughts on “Biml for a Task Factory Dynamics CRM Source Component”

  1. What issue are you encountering when generating a script component with Biml? I have been experiencing an issue when attempting to set the .NET target framework for a script component. I briefly highlighted the issue in this Biml forums post ( I sent an email to Varigence support too, but have not heard anything back concerning this issue.

    Thank you.

    1. Thanks, for your reply, Kevin. I ran into that issue as well.
      Unfortunately, I was using some additional libraries that required .Net 4.5.2 but my script component said it was 4.0 in the UI, even when I set the targeframeworkversion. But when I looked at the XML behind it, it said 4.5.2. Once I decided that was ok, I continued on and I got build warnings in my script component saying an external library required 4.0 while another required 4.2. Since those DLLs all came from the same download, which said it worked with 4.0, I decided something else was wrong. I tried running it anyway, but kept getting the following error “[SSIS.Pipeline] Error: The PrimeOutput method on “ExtractData” returned success, but did not report an end of the rowset. There is an error in the component. It should have reported an end-of-row. The pipeline will shut down execution to avoid unpredictable results.”. I had an explicit end of rowset in my code, and was explicitly calling GC.Collect in my postexecute method.

  2. So how did you create the BIML code that was part of the example? Did you use Variegence’s BIMLStudio or BIMLExpress? I’m interested in using BIML on my projects but haven’t had a good experience using BIML Express.

    1. When I needed to pull metadata from Dynamics, we used a .NET script. We just iterated through each entity and got the columns and data types and translated the datatypes into SQL data types. If you are on Dynamics 365 there are some solutions from Microsoft that might make life easier. There is the Data Export Service ( Also, keep an eye out for more info and enhancements to the Common Data Service for Apps (

  3. Hello Meagan

    Did you implement other Task Factory components in BIML, or was
    the Dynamics365 the only one.
    I am looking for an implementation of the Upsert destination.
    Maybe you have some hints for some sources.
    I have just startet with BIML Express and try to rebuild some of our existing pojects.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s