The specified column ‘X’ does not exist. The column with the most similar name is ‘X’

The specified column 'X' does not exist. The column with the most similar name is 'X'
The specified column ‘X’ does not exist. The column with the most similar name is ‘X’

Today I came across the following error message: The specified column ‘X’ does not exist. The column with the most similar name is ‘X’. This sounds like nonsense!

Explaining – The specified column ‘X’ does not exist

To explain the error message we will need to have a look at the code that was used:

UpdateContext(ctxUpdates,
 { 
     X :  "Any data"
 }
);

Patch(MyDB, 
      Lookup(MyDB, ID = 1),
      ctxUpdates);

The above code is a simplified version of the actual code. But the general idea should be clear. We are creating a variable that holds a record with a property X and then we are using that variable in a Patch that follows.

If we updated the code like this there will be no problem at all.

Patch(MyDB, 
      Lookup(MyDB, ID = 1),
      { 
         X :  "Any data"
      }
);

Why is the column not recognised?

When we look at the code there is no difference between the two names of the columns. So why is this failing. This is where we need to look at the internal names and display names of a property.

If we use the display names to update a column name then the Patch will be able to resolve the display name of a property to an internal name. If however we create an object using the Set function or the UpdateContext function then we are creating objects with the display names as properties.

Now if we look at our dataverse tables and we create an object with only the logical names as (shown below as ownerid for the Owner field) then the variables will match the table fields.

The specified column 'X' does not exist. The column with the most similar name is 'X'
The specified column 'X' does not exist. The column with the most similar name is 'X' 1

Why separate the update from the patch?

Why would we want to separate the update data from our Patch function.

Imagine that we want to do an update however depending on the update we want to either do a Patch or a SaveData (to the local device). Building up the data structure first before either running a Patch or a Save data without having to repeat the same data structure twice can be a good solution.


Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains

Subscribe now to keep reading and get access to the full archive.

Continue reading