Tuesday, March 14, 2017

Query Builder Error in MSDYN365

Query Build Error

The specified field does not exist in Microsoft Dynamics 365

I recently encountered this error in an on-premises environment one of my customers have. The issue occurs when I try to export the unmanaged solution, and it happened after I deleted a currency field from an entity that was included in the solution.
I managed to reproduce the issue in my online-environment, and I've sent a ticket to Microsoft so they might get it fixed soon, but I'll outline my findings in this blog post.

To reproduce this error, simply do the following (please do this in a dev-environment which you can break as you please, and back up all your solutions first):
  1. Create a new solution
  2. Add an existing entity to it
  3. Add an existing (or create a new) currency field
  4. Delete the currency field
  5. Try to export the solution (managed/unmanaged, happens with both)
You will probably be presented with this error message (unless it is fixed by the time you're reading this):


I tried to create each of the field types, it only fails on the currency type. I think this might have something to do with the secondary attribute which contains the currency base. In the back-end both option set and currency has two columns in the database, but only the currency field has a secondary field available in the UI.
If you mark both the currency and the currencybase field for deletion it will give you an error saying one attribute was not deleted, so that is not a viable workaround.
If you have created the entity in the solution you're working on then everything is OK, but if it's created in another solution (for example default solutions, or default entities) that are added as existing entities then this happens.

Workarounds (I prefer the first one, the other two are best for fresh installations and new solutions that haven't been through the normal ALM cycle yet):

  1. Restore a new dev environment (sandbox if you're online) from a backup, remove the field from the solution and export it as unmanaged. In the target dev-environment, make sure the field is deleted, then delete the solution (it's unmanaged, so the customizations will still be in place). Then import the newly exported solution which doesn't have the currency field included, it can now be exported as usual.
  2. Happens for unmanaged solutions, so you can just delete the solution and re-create it. Can be quite arduous, or near impossible, if you have included a lot of customization in the solution.
  3. Delete the entity and recreate it with the same id (only applicable for custom entities). Might be possible for simple entities without too much customization (will cause data loss). Can be re-created with the same id and schema and logical name so it doesn't break inheritance. I find this one most risky, so I would avoid it. Would work for solutions and entities that haven't been exported before.

4 comments:

  1. Hi,

    it seems I was able to fix this error in my solution by doing this:

    - Remove the entity from the solution (do not delete the entity)
    - Save and publish the changes (not sure if it's required)
    - Add the same entity back into the solution

    ReplyDelete
    Replies
    1. This worked with a pre-existing entity, but when the entity was created in the same solution there was no other choice but to delete the whole solution. I'm glad I had this in source control.

      Delete
  2. We're seeing this error often in Dynamics 365 (online) when trying to export solutions where we recreated one or more currency fields.

    And besides this bug, I really don't understand the decision by the product team to show error information that is not at all helpful.

    "Query Builder Error". What does that mean to someone trying to export the solution?

    "The specified field does not exist in Microsoft Dynamics 365."... with no indication what the "specified field" is.

    Then there's the "Show technical details" link that does nothing when you click it.

    We've had to start over with new solutions in order to work around this problem.

    ReplyDelete
    Replies
    1. This is a bug, so it's not surprising that we only get a generic error message.
      That said I really hope they are bringing in a fix soon, it doesn't look like it made it into the 2.1 update.

      Delete