Hi,
We would like to create tables on our database in order to clean data before importing it to dynamics 365 finance.
Is there an easy way to understand the column width and type of an entity so data is the correct size and type for an entity without going into the AOT and checking the entity column by column?
Thanks
Astrid
You are right, I was running the old version apparently. thanks!!!
ProductSubType is an enum, which is saved as INT in database. But it's true that enums can be exported either by the value (INT) or the symbol (string), depending on context.
Are you sure you're testing the updated code? I'm getting correct string sizes. If you're complaining about the same problem as before, maybe you're running old code.
Regarding the issue of exporting the entity staging table to a BYOD, we encounter an issue when trying to export Released Product V2, that the staging table has a column PRODUCTSUBTYPE which has a number and it is an INT column as an export to the database, but when we import it, it is an string 20 on the entity, there was another column on that entity with the same kind of issue.
Regarding your code, I do understand that the code needs work, we have adapted the code to include other type of columns, but we cannot understand what the string is always 10, we have debug the code and the data it gets, it is also 10. we do understand that the default for a string column while created is 10 too, we just don't understand how to get the real number, and not the default one.
thanks
Your statement about BYOD sounds strange to me. If a wrong schema was created in the external database, the export would fail, wouldn't it? Which specific field are you talking about?
Regarding the code, I've updated to include information from EDT. But note that I gave you the code as a demonstration of how to use metadata API, so you can start building your own solution. My intention isn't writing the whole thing for you.
Hi, We have tried but we are finding that all the string columns return a value of 10, which is not correct on any case, and we cannot find any attribute to add. Any idea where we are going wrong?
Thanks, I am sorry if I am not clear, but the issue is that I need to create a table on my database that matches the schema of the entity. We are trying to do some data quality work on the data we are going to import to dynamics and one of the issues we want to avoid is to have the wrong type of data or incorrect lengt.
Exporting the table to the BYOD does not work as the schema table can differ from the entity. One column on the entity was a string and on the staging table was an int.
I will test the code you sent. thanks
Another approach may be publishing data entities to BYOD and taking the schema from there.
It's a pity that you didn't tell us what problem you're dealing with, but anyway, I've created an example for your exact scenario. It's still just a demo; it doesn't cover all cases.
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Dynamics.AX.Metadata.MetaModel; using Microsoft.Dynamics.AX.Metadata.Storage; using Microsoft.Dynamics.AX.Metadata.Storage.Runtime; namespace DataEntityFields { public class Demo { public static void Main(string[] args) { var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory.GetApplicationEnvironment(); var runtimeConfiguration = new RuntimeProviderConfiguration(environment.Aos.PackageDirectory); var metadataProvider = new MetadataProviderFactory().CreateRuntimeProviderWithExtensions(runtimeConfiguration); AxDataEntityView entity = metadataProvider.DataEntityViews.Read("VendVendorV2Entity"); foreach (AxDataEntityViewMappedField entityField in entity.Fields.Where(f => f is AxDataEntityViewMappedField)) { var datasource = FindDataSource(entity.ViewMetadata.DataSources, entityField.DataSource); if (datasource == null) { continue; } AxTable table = metadataProvider.Tables.Read(datasource.Table); AxTableField field = table.Fields[entityField.DataField]; AxTableFieldString stringField = field as AxTableFieldString; if (stringField != null) { AxEdtString edt = null; if (stringField.ExtendedDataType != "") { edt = metadataProvider.Edts.Read(stringField.ExtendedDataType) as AxEdtString; } int stringSize = edt?.StringSize ?? stringField.StringSize; Console.WriteLine($"{entityField.Name} (String {stringSize})"); } } Console.ReadLine(); } private static AxQuerySimpleDataSource FindDataSource(IEnumerable dataSources, string dataSourceName) { foreach (AxQuerySimpleDataSource ds in dataSources) { if (ds.Name == dataSourceName) { return ds; } return FindDataSource(ds.DataSources, dataSourceName); } return null; } } }
We have been working on the code sample, but we are not familiar with the library, therefore we are not sure on how to adapt the code to get the entity metadata.
thanks, i will try it out
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CA Neeraj Kumar 2,339
André Arnaud de Cal... 824 Super User 2025 Season 2
Sohaib Cheema 600 User Group Leader