Wednesday, 18 November 2015

Solution Import Failed: The entity relationship role of the referencing entity is required when creating a new one-to-many entity relationship (0x80048470)

BEFORE WE GET STARTED

The source organization (where the solution was exported from) was CRM Online 2015. I am assuming Update 1.0. The version number found in solution.xml was 7.1.0001.3138.

The target organization (where the solution was being imported from) was CRM Online 2015 - Update 1.1 (7.1.1.4210).

THE STORY

In CRM Online (2015 Update 1.1), I exported a solution from one organization and imported it into another. When attempting to import the solution I received the typical (unhelpful) error:

An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support.

After inspecting the log file, I found the error message I needed:

The entity relationship role of the referencing entity is required when creating a new one-to-many entity relationship new_sharepointdocument_SharePointDocumentLocations.

Beside this message I noticed that this error occurred when CRM was attempting to process the sharepointdocument_SharePointDocumentLocations relationship.

Hold on a sec. What? Let's take a look at that again.

Name: sharepointdocument_SharePointDocumentLocations
ErrorText: new_sharepointdocument_SharePointDocumentLocations

Aww.
CRM.
(Pat on the head)

So, it appears that CRM isn't seeing this as a system/OOB relationship (notice the "new_" prepended to the name of the relationship). This may be the cause of the issue, or it may be the result of a deeper issue. Let's examine further.

If we open the solution .ZIP file and look at customizations.xml we find the following element/block:

    <EntityRelationship Name="sharepointdocument_SharePointDocumentLocations">
      <EntityRelationshipType>OneToMany</EntityRelationshipType>
      <IsCustomizable>1</IsCustomizable>
      <IntroducedVersion>1.0</IntroducedVersion>
      <IsHierarchical>0</IsHierarchical>
      <ReferencingEntityName>SharePointDocumentLocation</ReferencingEntityName>
      <ReferencedEntityName>SharePointDocument</ReferencedEntityName>
      <CascadeAssign>Cascade</CascadeAssign>
      <CascadeDelete>Cascade</CascadeDelete>
      <CascadeReparent>Cascade</CascadeReparent>
      <CascadeShare>Cascade</CascadeShare>
      <CascadeUnshare>Cascade</CascadeUnshare>
      <ReferencingAttributeName>RegardingObjectId</ReferencingAttributeName>
      <RelationshipDescription>
        <Descriptions>
          <Description description="Unique identifier of the object with which the SharePoint document location record is associated." languagecode="1033" />
        </Descriptions>
      </RelationshipDescription>
      <field name="regardingobjectid" requiredlevel="none" imemode="auto" lookupstyle="single" lookupbrowse="0" format="regarding">
        <IsSecured>0</IsSecured>
        <DisplayMask>ValidForAdvancedFind|ValidForForm|ValidForGrid</DisplayMask>
        <IsAuditEnabled>1</IsAuditEnabled>
        <displaynames>
          <displayname description="Regarding" languagecode="1033" />
        </displaynames>
      </field>
    </EntityRelationship>

Yup. It's definitely missing the EntityRelationshipRoles and EntityRelationshipRole elements (these usually follow the field element).

THE FIX

WARNING: These methods are technically unsupported. Your first consideration should be to contact Microsoft support regarding this issue - as it appears to be a bug.

Possibly, you could re-create the EntityRelationshipRoles and EntityRelationshipRole elements yourself (which I didn't test - so you're on your own if you choose that path). We could do this from finding another EntityRelationshipRole element in customizations.xml and using it as a template.

The better solution is to remove this block entirely. The effect will be that the sharepointdocument_SharePointDocumentLocations relationship that already exists in your target system will be left untouched. Unless you customized this relationship in some way, this is exactly what you want to happen.

Open the customizations.xml file from your solution .ZIP file, remove the EntityRelationship element/block, save your changes, and import the fixes .ZIP file, and voila!

Btw, I experienced the same problem with the sharepointsite_SharePointDocumentLocations relationship, so go ahead and remove the EntityRelationship element/block for that as well.

Wednesday, 30 October 2013

Microsoft Dynamics CRM for Outlook: Unable to connect to server (when outside of domain)

Okay. So, if you're an experienced Dynamics CRM administrator you've probably seen this error message before:
There is a problem communicating with the Microsoft Dynamics CRM server. The server might be unavailable. Try again later. If the problem persists, contact your system administrator.
I received this error message when trying to add an organization to Microsoft Dynamics CRM for Outlook.

And when we see this message we need to enable tracing so we can gather more (useful) data about the issue that lies beneath. See KB 2862031: How to enable tracing for the Microsoft Dynamics CRM for Outlook client for more information.

On this particular occasion, the log file gave me this much more specific error message:
The request for security token could not be satisfied because authentication failed.
 Ahh. My credentials are incorrect. But - what credentials were used? Configuration Wizard wasn't prompting me for credentials. Why?

Configuration Wizard knows that our client's machine is using Windows Authentication - and is assuming that I am a member of the domain that the server belongs to. This won't work because I am accessing the server through a VPN - from a machine that is not a member of that domain.

So... how can we get Configuration Wizard to prompt us for credentials? Is there another way to add an organization?

Microsoft Dynamics CRM for Outlook can be installed - AND CONFIGURED - using the command prompt. See Install Microsoft Dynamics CRM for Outlook using a Command Prompt for more information. And command prompts usually give us options that GUIs don't.

Today is no exception. And - it's the search for those options that leads us to our solution - which is found here:
The prompt (as well as the GUI in situations like these) requires credentials to already exist in Credentials Manager (a.k.a. Windows Vault) for the organization(s) you are trying to connect to.

So... we are going to enter those credentials into the Credentials Manager, and then run Configuration Wizard again.

Open a command prompt, and for each organization that you need to create a connection to, use the following command:
cmdkey /generic:Microsoft_CRM_{protocol}://{serverUrl}/ /user:{userName} /password
...to be prompted for a password, OR
cmdkey /generic:Microsoft_CRM_{protocol}://{serverUrl}/ /user:{userName} /password:{password}
...to enter your password in plain text.

EXAMPLE:
cmdkey /generic:Microsoft_CRM_https://contoso.crm.dynamics.com/ /user:user@contoso.com /password


This experience included:
  • Microsoft Dynamics CRM 2011 for Microsoft Office Outlook
  • Microsoft Dynamics CRM 2011 (On Premise)
  • Outlook 2013
  • Windows 8