Hi Guys,
kingswaysoft components allow simple operations like Retrieve, Update or Create, but when you need to do something more complex, there is no kingswaysoft components. But kingswaysoft provides two useful assemblies that you can uses them in a Script Task:
- KingswaySoft.DynamicsCrmServices
- KingswaySoft.IntegrationToolkit.DynamicsCrm
To do it follow this short toturial:
You need to create a Script Task in your Data Flow Process.
And to add your kingswaysoft crm connection manager to Connection Managers List:
After that you should to add kingswaysoft assemblies in reference like this :
Then, You should add kingswaysoft namespaces like this:
- #region Namespaces
- using System;
- using System.Data;
- using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
- using Microsoft.SqlServer.Dts.Runtime.Wrapper;
- using System.ServiceModel.Description;
- using KingswaySoft.IntegrationToolkit.DynamicsCrm;
- using KingswaySoft.DynamicsCrmServices.Soap2011;
- using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Query;
- using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService;
- #endregion
So, Now you need to create a IOrganizationService Object
- [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
- public class ScriptMain : UserComponent
- {
- KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.IOrganizationService orgService;
- ...
In PreExecute Methode, intialize your IOrganizationService Object using the AcquireConnection methode:
- public override void PreExecute()
- {
- base.PreExecute();
- var conn = (CrmConnection)Connections.CrmConnection.AcquireConnection(null);
- orgService = (KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.IOrganizationService)conn.GetCrmService();
- }
After that you can use all needed methods like RetrieveMultiple, Execute, Update etc...
Good Luck
N.JL
The script above will not work in SQL 2005 or 2008 because it requires .NET 4.0 . For a better alternative, check COZYROC SSIS+ library which has its own CRM backend which doesn't require .NET 4.0 . In addition COZYROC provides reusable scripts technology not found anywhere else.
ReplyDeleteHi Nizar,
ReplyDeleteThanks for provide such article to use ms CRM connection in to the script component. But unable to find the above mentioned assembly name "KingswaySoft.IntegrationToolkit.DynamicsCrm.dll". Can you please help me for that?
Thanks.
I did exactly what is mentioned here. unfortunately when I put a debug point on this it never hits and neither does any work.
ReplyDelete