Microsoft KB Archive/929277

= Error message when you try to integrate accounts in Microsoft Dynamics CRM 3.0 by using the Microsoft Dynamics CRM Connector: &quot;CustomerKey already exists and the UpdateIfExists flag is set to not allow updates&quot; =

Article ID: 929277

Article Last Modified on 8/15/2007

-

APPLIES TO


 * Microsoft Dynamics CRM 3.0
 * Microsoft Dynamics CRM Connector for Microsoft Dynamics GP, when used with:
 * Microsoft Dynamics CRM 3.0

-



SYMPTOMS
You try to integrate multiple accounts in Microsoft Dynamics CRM 3.0 as customers in Microsoft Dynamics GP by using the Microsoft Dynamics CRM Connector for Microsoft Dynamics GP. If the account name of the first account contains 14 alphanumeric characters that are followed by a space character, the first account is integrated successfully. However, successive accounts that have account names that are 14 characters long may not be integrated as expected. Additionally, you receive the following error message:

CustomerKey already exists and the UpdateIfExists flag is set to not allow updates.

If account names that contain 14 alphanumeric characters that are followed by a space character are integrated to Microsoft Dynamics GP, and if you update the first such customer record in Microsoft Dynamics GP, a duplicate account is created in Microsoft Dynamics CRM.

Consider the following scenario:
 * You create an account in Microsoft Dynamics CRM that is named Colorado State University. Notice that this account name cannot exist in Microsoft Dynamics CRM. Additionally, the name must have a blank space as the 15th character in Microsoft Dynamics CRM. For example, you can also create an account in Microsoft Dynamics CRM that is named Nebraska State University.
 * This new record integrates to Microsoft Dynamics GP. The record has a Customer ID value of &quot;Colorado State&quot; and a customer name of Colorado State University. You update the customer record in Microsoft Dynamics GP. For example, you change the e-mail address.
 * You expect this record to integrate to Microsoft Dynamics CRM as an update to the existing record for Colorado State University. However, a duplicate account is instead created in Microsoft Dynamics CRM. The account name for the duplicate record is Colorado State University. The new account now links to the customer in Microsoft Dynamics GP.



CAUSE
This issue may occur because the Microsoft Dynamics CRM Connector uses the value in the Account Name field in Microsoft Dynamics CRM 3.0 to create the value in the customer number (CUSTNMBR) field in Microsoft Dynamics GP.

By default, the value in the Account Name field in Microsoft Dynamics CRM 3.0 can contain up to 160 characters. In Microsoft Dynamics GP, the value in the CUSTNMBR field can contain only 15 characters. When the value in the CUSTNMBR field is created during the integration process, the space character that follows an account name that is 14 characters long causes a duplicate CUSTNMBR value to be created.



WORKAROUND
To work around this issue, update the Microsoft Dynamics CRM Connector maps on the computer that is running Microsoft BizTalk Server. To do this, follow these steps.

Step 1: Set up the BizTalk Visual Studio Projects for the Microsoft Dynamics CRM Connector
 Create a new blank solution in Microsoft Visual Studio. To do this, follow these steps:  Start Microsoft Visual Studio .NET 2003. On the File menu, click New, and then click Blank Solution. In the Name box, type IntegrationSolution as the name of the solution, and then click OK.  Copy the SchemaMaps folder from the Microsoft Dynamics CRM Connector installation location to the root folder for the blank solution. To do this, follow these steps:  Locate the installation files for the Microsoft Dynamics CRM Connector.</li> Right-click the SchemaMaps folder, and then click Copy.</li> Locate the IntegrationSolution solution. By default, the solution is located in the following folder:

C:\Documents and Settings\ \My Documents\Visual Studio Projects

</li> Open the IntegrationSolution folder.</li> Right-click a blank area in the folder, and then click Paste.</li></ol> </li> Add the three BizTalk projects in the SchemaMaps folder to the blank solution. To do this, follow these steps:  On the View menu, click Solution Explorer.</li> Right-click the solution in Solution Explorer, click Add, and then click Existing Project.</li> Open the SchemaMaps folder, and then open the CRMSchemas folder.</li> Double-click the CRMSchemas.btproj file.</li> Right-click the solution in Solution Explorer, click Add, and then click Existing Project.</li> Open the GPSchemas folder.</li> Double-click the GPSchemas.btproj file.</li> Right-click the solution in Solution Explorer, click Add, and then click Existing Project.</li> Open the Mapscrmgp folder.</li> <li>Double-click the Mapscrmgp.btproj file.</li></ol> </li> <li>Create a strong name key file to sign the output of each project. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Click Start, point to All Programs, point to Microsoft Visual Studio .NET 2003, point to Visual Studio .NET Tools, and then click Visual Studio .NET 2003 Command Prompt.</li> <li>At the command prompt, type the following command, and then press ENTER:

sn -k \ .snk

</li></ol> </li> <li>Set up each project to use the strong name key file to sign the output of each project. To do this, follow these steps in Microsoft Visual Studio for each project in the IntegrationSolution solution: <ol style="list-style-type: lower-alpha;"> <li>Right-click the project, and then click Properties.</li> <li>Under Common Properties, click Assembly.</li> <li>In the Strong Name area, click False in the Assembly Delay Sign box.</li> <li>In the Assembly key file box, type the path of the .snk file that you created in step 4.</li> <li>Click OK.</li></ol> </li> <li>Add references to the integration .dll files. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Expand the MapsCRMGP project, expand References, right-click the following references, and then click Remove: <ul> <li>Microsoft.MbsIntegration.CRMSchemas</li> <li>Microsoft.MbsIntegration.GPSchemas</li> <li>Microsoft.MbsIntegration.FunctoidsCRMGP</li></ul> </li> <li>Right-click References, and then click Add Reference.</li> <li>Click Browse, and then locate the Microsoft.MbsIntegration.FunctoidsCRMGP.dll file.

By default, the Microsoft.MbsIntegration.FunctoidsCRMGP.dll file is in the same folder as the Microsoft Dynamics CRM Connector installation files.</li> <li>Click the Microsoft.MbsIntegration.FunctoidsCRMGP.dll file, and then click Open.</li> <li>Right-click References, and then click Add Reference.</li> <li>On the Projects tab, select the CRMSchemas project and the GPSchemas project, click Select, and then click OK.</li></ol> </li> <li>Change the assembly name for the MapsCRMGP project output. To do this, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>Right-click the MapsCRMGP project, and then click Properties.</li> <li>Under Common Properties, click General.</li> <li>In the Assembly name box, click Microsoft.MbsIntegration.MapsCRMGPCustom, and then click OK.</li></ol> </li></ol>

Step 2: Update the Crm_account_to_gp_customer.btm BizTalk map
In this step, you use a scripting functoid to remove spaces from the value that is mapped to the CUSTNMBR node. The value that is mapped to the CUSTNMBR node is in the Crm_account_to_gp_customer.btm BizTalk map of the MapsCRMGP project in the solution.

To do this, follow these steps: <ol> <li>Expand the MapsCRMGP project.</li> <li>Expand the AccountCustomer folder.</li> <li>Double-click the Crm_account_to_gp_customer.btm file.</li> <li>Under Advanced Functoids in the Microsoft Visual Studio toolbox, drag a scripting functoid to the Mapping area.</li> <li>On the right side of the mapping file, locate the CUSTNMBR node.</li> <li>Locate and then select the link that connects the CUSTNMBR node to the scripting function in the map.

Note When you select the link node, the link node will change to blue.</li> <li>Click the end of the link that connects the CUSTNMBR node, and then drag that end to the new scripting functoid that you added to the Mapping area.</li> <li>Click the scripting functoid that you connected by using the link, and then drag the scripting functoid to the CUSTNMBR node.

You should now have a scripting functoid that is linked to another scripting functoid. Additionally, the scripting functoid should be linked to the CUSTNMBR node.</li> <li>Right-click the scripting functoid that you added to the Mapping area, and then click Properties.</li> <li>Click the ellipsis button (...) for the Script property. The Configure Functoid Script dialog box opens.</li> <li>In the Script type box, click Inline C#.</li> <li>In the Inline script buffer box, select and then delete the text.</li> <li> Copy the following code into the Inline script buffer text area, and then click OK. public string ReplaceSpaces(string custnmbr) {  custnmbr = custnmbr.Replace(&quot; &quot;,&quot;&quot;); return custnmbr; } </li> <li>On the Build menu, click Build MapsCRMGP.</li></ol>

Step 3: Publish the customized Crm_account_to_gp_customer.btm BizTalk map
In this step, you update the Crm_account_to_gp_customer.btm BizTalk map by using the Setting and Administration Tool on the server that is running the Microsoft Dynamics CRM Connector. To do this, follow these steps: <ol> <li>Click Start, point to All Programs, point to Microsoft CRM Connector for Microsoft Dynamics GP, and then click Setting and Administration Tool.</li> <li>Click Administration, and then click Integration Server.</li> <li>Click the Customize Maps tab.</li> <li>Click Add Map.</li> <li>Locate and then open the Microsoft.MbsIntegration.MapsCRMGPCustom.dll file.</li> <li>In the Add New Map Web Page dialog box, click Select Map, and then click Microsoft.MbsIntegration.MapsCRMGP.crm_account_to_gp_customer. Then, follow these steps: <ol style="list-style-type: lower-alpha;"> <li>In the Map description type box, type a description for the map.</li> <li>In the Event box, click Create.</li> <li>In the Source application box, click Microsoft CRM.</li> <li>In the Source entity box, click Account.</li> <li>In the Destination application box, click Microsoft Great Plains.</li> <li>In the Destination entity box, click Customer.</li> <li>Click Deploy Maps.</li></ol> </li> <li>Click OK.</li> <li>Click Start, point to All Programs, point to Administrative Tools, and then click Services.</li> <li>Restart the following services: <ul> <li>BizTalkServerApplication</li> <li>MBSIntSendHost</li></ul> </li></ol>

Additional query words: crm3 crm30 crm3.0 connector

Keywords: kbtshoot kbexpertiseinter kberrmsg kbmbsmigrate kbprb KB929277

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.