Skip to main content

Remove unsupported characters with Sanitizing Your #msdyn365bc Data.

Hi Readers,

With start of New Year, I saw a new issue and learned something with that.

This reminded about an old article that I have written in past during data upgrade from Classic to RTC Version.

While writing that I thought this will never come up again but to my surprise that it's still there, but this time story is little bit different. This time Microsoft added a process to fix these data issues.

What is the Error Message?

The item cannot be deleted via the User Interface or extension.


Why is the Error Message?

This is due to unsupported characters from fields of type "Code" in the tenant database. 


What are unsupported characters?

Leading and trailing Unicode white-space characters from a field. 

These characters are invisible characters, and represent a keystroke like Enter, TAB or space bar.


How to Fix these Issues?

Last time when we did this with a two-step process.

  • Identification - That was done via SQL Query. (Only primary key fields).
  • Fix - Via NAV Client to make sure related records are also updated.

** If you are still upgrading from Pre NAV 2013 then please refer old post.

If you / your customer is already in Business Central 14 or higher then Microsoft added a PowerShell cmdlet to fix it.


What is the PowerShell Cmdlet?

  • This PowerShell cmdlet is added in Business Central Administration Shell Module. 
  • The cmdlet is Invoke-NAVSanitizeField.


What does Invoke-NAVSanitizeField command does?

  • This cmdlet deletes all the unsupported characters from fields of type "Code" in the tenant database. 
  • It trims leading and trailing Unicode white-space characters from a field. 
  • These characters are invisible characters, and represent a keystroke like Enter, TAB or space bar. The cmdlet is similar to the System.Trim method. For a list of the Unicode characters, see IsWhiteSpace method.
  • The cmdlet returns an object containing the number of rows and values modified, the tables impacted and a list of potentially ignored records.


What are cmdlet Parameters?

  • Server Instance - Specifies the name of a Business Central Server instance.
  • Company Name  - Specifies the name of the company that you want to run the operation on. If you do not set this parameter, the operation will run on all companies.
  • Tenant - If multitenant then Specifies the ID of the tenant otherwise keep it empty.
  • TableId  - Specifies the ID of the table that you want to invoke the operation on. If you do not set this parameter, the operation will run on all tables.
  • FieldId - Specifies the ID of the field that you want to invoke the operation on. If you do not set this parameter, the operation will run on all fields of the table.
  • RemoveDuplicates - Specifies to delete a record, after it's been sanitized, if it conflicts with an existing record. 

When you Should Run It?

  • Before you start replicating your data to Business Central online (SaaS), please make sure to run it. 
  • With Execution of this cmdlet, you will be sure that if there are any unsupported characters in data that will be clean.
  • I would highly encourage to run this even on prem during upgrade process.


How to Run this PowerShell cmdlet?

To run this simply on complete database to analyze run this with minimum set of parameters.

Invoke-NAVSanitizeField -ServerInstance BC210 


You can surely add parameters if required. The RemoveDupicates switch will delete duplicate records that is only applicable to primary key fields.


 After the query, check data from SQL Server. The command will update the data in database.


Microsoft Article.

Let me know your views as comment to this article.

Hope this helps your future.

Comments

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

RTC Report It is not possible to instantiate the Visual Studio bridge.

Hi all, As a Navision developers I have Multiple Versions of Navision running in single Machine. As discussed Earlier in the post how to run multiple Version of RTC in single machine. So my machine have following details for RTC Versions - NAV 2009 R2    - is installed. NAV 2009 SP1  - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 SP1 IN\ NAV 2009         - is copied at C:\Program Files (x86)\Microsoft Dynamics NAV\60\NAV 6.0 IN\ This approach has been working great for execution of Classic and RTC Clients. However, after installing Dynamics NAV 2009 R2, if i tried to view the Layout for an NAV 2009 SP1 Report i was getting the following error: ---------------------------  Microsoft Dynamics NAV Classic  ---------------------------  It is not possible to instantiate  the Visual Studio bridge.  ---------------------------  OK    --------------------------- After searchi...

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.