SSIS/Kingsway MSCRM-Lookup per ScriptComponent

 

Verweise:

//KingswaySoft.DynamicsCrmServices   
//Pfad: C:\WINDOWS\assembly\GAC_MSIL\KingswaySoft.DynamicsCrmServices\1.0.0.0__705df8e0751bcea7\KingswaySoft.DynamicsCrmServices.dll
//KingswaySoft.IntegrationToolkit.DynamicsCrm   
//Pfad: C:\Program Files (x86)\Microsoft SQL Server\120\DTS\PipelineComponents\KingswaySoft.IntegrationToolkit.DynamicsCrm.dll

Namespaces im Code:

using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService;
using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Messages;
using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Metadata;
using KingswaySoft.DynamicsCrmServices.Soap2011.OrganizationService.Query;
using KingswaySoft.IntegrationToolkit.DynamicsCrm;

Code:

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        /*
         * Add your code here
         * 
         * http://www.kingswaysoft.com/blog/2013/06/24/Writing-Script-Component-or-Script-Task-using-CRM-Connection-Manager
         */

        //var connMgr = this.Connections.Dynamics365;
        //var conn = (CrmConnection)connMgr.AcquireConnection(null);

        var connMgr = this.Connections.Dynamics365;
        var connectionString = (string)connMgr.AcquireConnection(null);
        var conn = new CrmConnection(connectionString);

        var orgService = (IOrganizationService)conn.GetCrmService();

        //Select parentcustomerid from contact where contact = '00000-0000000000-00000-00000-0000'
        var inputValue = Row.contactid;  // input0: Field "contactid"
        var retrievedEntity = orgService.Retrieve("account", parmInputvalue, new ColumnSet("parentcustomerid"));
        var outputValue = retrievedEntity.GetAttributeValue("parentcustomerid");
        Row.parentcustomerid = outputValue;  // output0: new Field "parentcustomerid"
    }
</pre