{"id":13315,"date":"2018-11-08T16:39:23","date_gmt":"2018-11-08T11:09:23","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=13315"},"modified":"2018-11-08T16:39:23","modified_gmt":"2018-11-08T11:09:23","slug":"how-to-set-all-party-list-values-while-migrating-data-of-activities-using-ssis-with-kingsway-soft-tool","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2018\/11\/how-to-set-all-party-list-values-while-migrating-data-of-activities-using-ssis-with-kingsway-soft-tool\/","title":{"rendered":"How to set all Party list values while migrating data of Activities using SSIS"},"content":{"rendered":"<p style=\"text-align: justify;\">While doing data migration of Activity entities like Email, Phone call which has Party list fields like to, from, bcc, cc etc. where we set all values i.e. lookups of different entities like Account, Contact, Lead, User, Queue etc. and manually entered an email address for e.g. <a href=\"mailto:abc@gmail.com\" target=\"_blank\" rel=\"noopener noreferrer\">abc@gmail.com<\/a>. While setting these party-list values, I was unable to set manually entered email address value because it is not an entity, it is a simple field which holds values in backend.<\/p>\n<p style=\"text-align: justify;\">The main cause behind this is while setting other lookups like account, contact etc. we have logical name of entities and its object type code i.e. account has 1, contact has 2 etc., But in case of manually entered email address we do not have its logical name because it is a Field, so due to this while setting the party list data I was unable to set such values in it.<\/p>\n<p style=\"text-align: justify;\">This blog will help you to fix this issue and how to set all party list values including <strong>address used<\/strong> value while migrating Activities data.<\/p>\n<h2 style=\"text-align: justify;\">Solution:<\/h2>\n<p style=\"text-align: justify;\">To set all values of party-list field we used <strong>Script <\/strong>component where we to write a code that will update the records. To achieve this we followed below steps:<\/p>\n<h2 style=\"text-align: justify;\">Step 1:<\/h2>\n<p style=\"text-align: justify;\">Initially, we need to create project level connection parameters as shown in below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-13316\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/1How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"821\" height=\"176\" \/><\/p>\n<h2>Step 2:<\/h2>\n<p style=\"text-align: justify;\">Once connection parameters created then we need to create SSIS package for activity for e.g. <strong>Email<\/strong> where we will create email record in Destination CRM as highlighted in below screen clip:<\/p>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13317\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/2How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"612\" height=\"334\" \/><\/p>\n<p>While creating record in Destination CRM, initially we need to remove mapping of party list fields as shown in below screen clip:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-13318\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/3How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"744\" height=\"417\" \/><\/p>\n<h2>Step 3:<\/h2>\n<p style=\"text-align: justify;\">Once record created in Destination CRM after then we need to update party list values of record in Destination CRM, for that follow below steps:<\/p>\n<ul>\n<li style=\"text-align: justify;\">To updating the record we need a <strong>Script component<\/strong> of Kingsway soft tool where we have to write the code to update party list of records. As we can see in below screen clip, the SSIS package initially creates record after then updates the record by using <strong>update()<\/strong> with the help of Microsoft.Xrm.sdk and Microsoft.Crm.sdk.proxy DLL\u2019s.<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13319\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/4How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"607\" height=\"321\" \/><\/p>\n<ul>\n<li style=\"text-align: justify;\">In above-highlighted portion of screen clip, initially we need to set parameters which we created in <strong>Step 1 <\/strong>as shown in below screen clip :<\/li>\n<\/ul>\n<p style=\"padding-left: 30px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13320\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/5How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"661\" height=\"665\" \/><\/p>\n<ul>\n<li style=\"text-align: justify;\">Once we have done with the above step, we need to create one folder where we have to place <strong>Xrm.sdk<\/strong> and <strong>Microsoft.Crm.sdk.proxy <\/strong>DLL files which we are going to add them in references as shown in below screen clip:<\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13330\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/Capture.jpg\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"668\" height=\"321\" \/><strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0References<\/strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<strong>Namespace\u2019s<\/strong><\/p>\n<ul>\n<li>After adding <strong>references<\/strong> and <strong>namespaces<\/strong> we need to add new class file as shown in below screen clip which contains code which is use to update the record:<br \/>\n<h3><strong>Write below code in CRMHelper.cs file<\/strong><\/h3>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-13323 \" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/8How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"820\" height=\"340\" \/><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-13324 \" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/9How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"814\" height=\"411\" \/><\/p>\n<p style=\"padding-left: 30px;\"><strong>Write below code in main.cs file<\/strong><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-13325 size-full\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/10How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"808\" height=\"226\" \/><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-13326 \" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/11How-to-set-all-Party-list-values-while-migrating-data-of-Activities-using-SSIS-with-Kingsway-soft-tool.png\" alt=\"How to set all Party list values while migrating data of Activities using SSIS with Kingsway soft tool\" width=\"814\" height=\"438\" \/><\/p>\n<ul>\n<li>\n<h3><strong>Below is the code of GetActivity() function<\/strong><\/h3>\n<\/li>\n<\/ul>\n<p>GetActivity() function required to pass 3 parameters i.e. <strong>Input Row<\/strong>, <strong>Activity name<\/strong> and <strong>Participation type mask<\/strong> as we can see in above screen clip.<\/p>\n<pre class=\"lang:default decode:true\">private EntityCollection GetActivity(ref Input0Buffer Row, string Activity, string ParticipationTypeMask)\n    {\n        #region FunctionLevelVariable\n        string functionName = \"GetActivity\";\n        int RegObjTypecode;\n        EntityCollection ary = new EntityCollection();\n        #endregion\n        try\n        {\n            \/\/Connectionstring to get connect to DB\n            string connectionString = \"Data Source=sql(i.e. Server Name);Initial Catalog=CRM(i.e. Database Name);Integrated Security=true\";\n            string sqlQuery = string.Empty;\n            SqlConnection sqlConnection = null;\n            int partylistCount = 0;\n            string temp = string.Empty;\n            DataSet ActivityDataSet = new DataSet();\n            SqlDataAdapter dataAdapter = new SqlDataAdapter();\n            sqlConnection = new SqlConnection(connectionString);\nsqlQuery = \"select FilteredActivityParty.PartyId, FilteredActivityParty.PartyObjectTypeCode, FilteredActivityParty.ParticipationTypeMask, FilteredActivityParty.PartyIdName, FilteredActivityParty.ActivityId, FilteredActivityParty.IsPartyDeleted, FilteredActivityParty.AddressUsed, FilteredActivityParty.PartyIdName from FilteredActivityParty \";\n           \t sqlQuery += \" inner join\u201d + Activity + \" on \" + Activity + \".ActivityId = FilteredActivityParty.ActivityId\";\n            \tsqlQuery += \" where \" + Activity + \".ActivityId ='\" + Row.activityid.ToString() + \"'\"; \n            SqlCommand command = sqlConnection.CreateCommand();\n            command.CommandText = sqlQuery;\n            command.CommandType = CommandType.Text;\n            dataAdapter.SelectCommand = command;\n   dataAdapter.Fill(ActivityDataSet);\n\/\/Retrive parties based on its ParticipationTypeMask\nDataRow[] parties = ActivityDataSet.Tables[0].Select(\"ParticipationTypeMask = \" + ParticipationTypeMask);\n\n            \/\/check length \n            if (parties.Length &gt; 0)\n            {\n                foreach (DataRow row in parties)\n                {\n                    #region foreach level variables\n                    Entity apto = new Entity(\"activityparty\");\n                    Entity ap1 = new Entity(\"activityparty\");\n                    Entity ap2 = new Entity(\"activityparty\");\n                    Entity ap4 = new Entity(\"activityparty\");\n                    Entity ap8 = new Entity(\"activityparty\");\n                    Entity ap2020 = new Entity(\"activityparty\");\n                    #endregion\n\n                    if (partylistCount == 120)\n                    {\n                        break;\n                    }\n                    int PartyObjectTypeCode = Convert.ToInt32(row[\"PartyObjectTypeCode\"]);\n                    switch (PartyObjectTypeCode)\n                    {\n                        case 0:\n\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                if (PartyObjectTypeCode == 0)\n                                {\n                                    if (row[\"AddressUsed\"] != \"\" || row[\"AddressUsed\"] !=string.Empty)\n                                    {\n                                        apto[\"addressused\"] = row[\"AddressUsed\"];\n                                        ary.Entities.Add(apto);\n                                    }\n                                }\n                            }\n                            break;\n\n                        case 1:\n\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                ap1[\"partyid\"] = new EntityReference(\"account\", new Guid(row[\"PartyId\"].ToString()));\n                                ary.Entities.Add(ap1);\n                            }\n                            break;\n\n                        case 2:\n\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                ap2[\"partyid\"] = new EntityReference(\"contact\", new Guid(row[\"PartyId\"].ToString()));\n                                ary.Entities.Add(ap2);\n                            }\n                            break;\ncase 4:\n\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                ap4[\"partyid\"] = new EntityReference(\"lead\", new Guid(row[\"PartyId\"].ToString()));\n                                ary.Entities.Add(ap4);\n\n                            }\n                            break;\n\n                        case 8:\n\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                string userGUID = getUserGUID(row[\"PartyIdName\"].ToString());\n                                ap8[\"partyid\"] = new EntityReference(\"systemuser\", new Guid(userGUID));\n                                ary.Entities.Add(ap8);\n                            }\n                            break;\n\n                        case 2020:\n                            if (row[\"IsPartyDeleted\"].Equals(false))\n                            {\n                                ap2020[\"partyid\"] = new EntityReference(\"queue\", new Guid(row[\"PartyId\"].ToString()));\n                                ary.Entities.Add(ap2020);\n                            }\n                            break;\n                    }\n                }\n            }\n            return ary;\n        }\n        catch (Exception e)\n        {\n            return null;\n        }\n}<\/pre>\n<p style=\"text-align: justify;\">In above code, we can see the highlighted function in Yellow i.e. <strong>getUserGUID()<\/strong> function which is used to get users GUID of destination CRM based on the name of Users as they are present in Source CRM. To get the Destination Users GUID please use below code:<\/p>\n<pre class=\"lang:default decode:true\">public string getUserGUID(string onpremiseUsername)\n    {\n        #region Function Level Varibles\n        string functionName = \"getUserGUID\";\n        var listOfOnPreUserNames = new List&lt;string&gt;();\n        var listOfOnlineUserNameIds = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();\n        string OnLineUseGUID;\n        int indexOfGuid;\n        #endregion\n        try\n        {\n            #region List of Onpremise users\n            listOfOnPreUserNames.Add(\"ABC\");\n            listOfOnPreUserNames.Add(\"XYZ\");\n\n#region List of Online 365 User name &amp; ID\n            listOfOnlineUserNameIds.Add(new KeyValuePair&lt;string, string&gt;(\"da4a442d-32b5-e811-a987-000d3a18032d\", \" ABC \"));\n            listOfOnlineUserNameIds.Add(new KeyValuePair&lt;string, string&gt;(\"40976433-32b5-e811-a987-000d3a18032d\", \" XYZ \"));\n#endregion\n\/\/get index of founded user\n            indexOfGuid = listOfOnPreUserNames.IndexOf(onpremiseUsername);\n\n            \/\/if index is -1 it means user does not contain in users list\n            if (indexOfGuid != -1)\n            {\n                \/\/Retrive Online users GUID\n                OnLineUseGUID = listOfOnlineUserNameIds[indexOfGuid].Key;\n            }\n            else\n            {\n                \/\/set Default user\n                OnLineUseGUID = \"03eb25a2-122d-405d-bfaf-de5fdea4a8af\";\n            }\n        }\n        catch (Exception ex)\n        {\n            throw new Exception(functionName + \"&lt;&lt;\" + ex.Message);\n        }\n        return OnLineUseGUID;\n    }<\/pre>\n<h2><strong>Conclusion:<\/strong><\/h2>\n<p style=\"text-align: justify;\">Using <strong>Service.Update() <\/strong>in Script component we can set all party list values like Account, Contact, Users or Address used in <strong>Activities<\/strong> which has <strong>party list<\/strong> fields.<\/p>\n<p>\u00a0<a href=\"https:\/\/www.inogic.com\/product\/integrations\/inolink-quickbooks-microsoft-dynamics-crm\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-13332 \" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/11\/Banner-InoLink-QuickBooks-Integration-with-Microsoft-Dynamics-365-Dynamics-CRM-1.jpg\" alt=\"Banner InoLink-QuickBooks-Integration-with-Microsoft-Dynamics-365-Dynamics-CRM (1)\" width=\"825\" height=\"102\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/integrations\/inolink-quickbooks-microsoft-dynamics-crm\">\u00a0<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While doing data migration of Activity entities like Email, Phone call which has Party list fields like to, from, bcc, cc etc. where we set all values i.e. lookups of different entities like Account, Contact, Lead, User, Queue etc. and manually entered an email address for e.g. abc@gmail.com. While setting these party-list values, I was\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2018\/11\/how-to-set-all-party-list-values-while-migrating-data-of-activities-using-ssis-with-kingsway-soft-tool\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":13327,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[16,18,19,57],"tags":[977,1655,1661],"class_list":["post-13315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-ssis","tag-kingsway-soft-tool-dynamics-crm","tag-ssis-dynamics-365","tag-ssis-with-kingsway-soft-tool"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/13315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=13315"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/13315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/13327"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=13315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=13315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=13315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}