Dynamics NAV/CRM connector - CRM throws JS error on Submit

katkokatko Member Posts: 11
edited 2015-06-16 in Dynamics CRM
Dynamics CRM 2013 (SP1 + rollups 1,2,3) and Dynamics NAV 2013 R2 are connected with the most recent version of the connector.

I can get NAV records to sync toward CRM. CRM, however, has problems.

Standard procedure for syncing CRM -> NAV is to explicity mark records in CRM with the "Submit" button. This prepares the record for integration with NAV, and serves to prevent records in CRM unrelated to NAV from being synced over.

The connector itself, seems ready and willing to receive records from CRM. However, pressing the submit button shows a slight glitch on the form, and only after clicking away from the form page does Microsoft Dynamics CRM throw a general "invalid reference" error.

It turns Javascript is throwing an exception when I press the Submit button. The error seems either due to a misconfigured JS script, or a misconfigured db and the dereference fails because data is missing.

Here is the relevant script and error (Sorry if the big picture messes up the forums formatting):
NDmzQyq.png

The CRM installation is fresh and empty. I then applied all service packs/hotfixes. Then I installed and setup the connector and it set it successfully uploaded the configuration data (which I assume contains the Javascript additions and any db changes).

And the fields that seem missing like dynamics_isreadyforintegration show up in CRM's field browser!

Comments

  • katkokatko Member Posts: 11
    Does anyone have any ideas, things to look for?

    The connector, and CRM are running on domain accounts. All software (except the domain controller) is on the same computer.

    I checked in the "imported solutions" tab and it shows a successful import.

    I have a question though, for CRM 2013, you're supposed to use the 2011 solution, correct? That's autoselected, but there's also a zip for the 2015 edition.

    Also, I installed and fully patched Dynamics CRM 2013 BEFORE installing the connector. That shouldn't cause any problems, should it? I couldn't find any documentation at all requiring a specific order of install vs patching.
  • katkokatko Member Posts: 11
    I noticed some more strangeness.

    If I add a field that it fails on directly to the form, it passes that request without an exception. So I added EACH one of the requests from this snippet of code:
    function Dynamics_Integration_account_Form_Group0_Control0_1()
    {
    	if(Xrm.Page.getAttribute("dynamics_isreadyforintegration").getValue() == false)
    	{
    		Xrm.Page.getAttribute("dynamics_isreadyforintegration").setValue(true); 
    		Xrm.Page.getControl("dynamics_isreadyforintegration").setDisabled(true); 
    		Xrm.Page.getAttribute("dynamics_isreadyforintegration").setSubmitMode("always"); 
    		Xrm.Page.getAttribute("dynamics_integrationkey").setSubmitMode("always"); 
    		Xrm.Page.getAttribute("accountnumber").setSubmitMode("always"); 
    		Xrm.Page.getAttribute("address1_name").setSubmitMode("always");
    		Xrm.Page.getAttribute("address1_country").setSubmitMode("always");
    		if(Xrm.Page.getAttribute("address2_name") != null)
    		{
    			Xrm.Page.getAttribute("address2_name").setSubmitMode("always");
    		}
    		if(Xrm.Page.getAttribute("address2_country") != null)
    		{
    			Xrm.Page.getAttribute("address2_country").setSubmitMode("always");
    		}
    		if(Xrm.Page.getAttribute("primarycontactid") != null)
    		{
    			Xrm.Page.getAttribute("primarycontactid").setSubmitMode("always");
    		}
    	}	
    	Xrm.Page.data.entity.save();
    }
    

    And it then pass the javascript section, but then throws a Business Rule error when you click Submit:
    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: You must supply a valid, non-empty value for the Account Number if you are integrating this account with a Microsoft Dynamics ERP product.Detail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220891</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>CallStack</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">   at Microsoft.Dynamics.Integration.Adapters.Crm2011.Plugin.AccountCreateUpdateEventHandler.Execute(IServiceProvider serviceProvider)
       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IServiceEndpointNotificationService serviceBusService, IOrganizationServiceFactory organizationServiceFactory, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)
       at Microsoft.Crm.Sandbox.SandboxAppDomainHelper.Execute(IServiceEndpointNotificationService serviceBusService, IOrganizationServiceFactory organizationServiceFactory, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, IPluginExecutionContext requestContext)
       at Microsoft.Crm.Sandbox.SandboxWorker.Execute(SandboxCallInfo callInfo, SandboxPluginExecutionContext requestContext, Guid pluginAssemblyId, Int32 sourceHash, String assemblyName, Guid pluginTypeId, String pluginTypeName, String pluginConfiguration, String pluginSecureConfig, SandboxRequestCounter& workerCounter)</d2p1:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">1</d2p1:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <d2p1:key>SubErrorCode</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">-2146233088</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>You must supply a valid, non-empty value for the Account Number if you are integrating this account with a Microsoft Dynamics ERP product.</Message>
      <Timestamp>2015-05-18T19:30:36.0312958Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText>
    
    [Microsoft.Dynamics.Integration.Adapters.Crm2011.Plugin: Microsoft.Dynamics.Integration.Adapters.Crm2011.Plugin.AccountCreateUpdateEventHandler]
    [208c9461-bfe9-df11-9ec8-00155d52bcec: Update of account]
    
    
    </TraceText>
    </OrganizationServiceFault>
    
    Most notably, you must specify an account number. So I manually specify an account number and head back to the account... The Submit button disappears!

    So I run the connector now, and it syncs it over!

    This is insanity. I cannot figure out what's broken here. I have a terrible, workaround solution... but I have no idea what the ramifications of letting users manually set that field (but forgetting any other required fields) will be.
  • katkokatko Member Posts: 11
    On further inspection, this method of manually adding the fields appears to work. A blank CRM and mostly blank NAV sync over.

    The only caveat is forcing the user to specify and account name before they sync. Which makes sense (NAV requires an account), but I'm not really sure if that's the standard functionality--or if CRM is supposed to generate an account number, or NAV should work without account numbers.

    I've got a new problem, I'll post another thread for that.
Sign In or Register to comment.