*This post is locked for comments
*This post is locked for comments
Thank you Martin!
As soon as I learned how to navigate those metadata classes from C#, life seems easier.
In my case answer was behind
.GetPrimaryKeysWithModelInfo(); - it gives combination of entity extension name and its model.
MetadataSupport has some methods for this purpose, but they're internal, therefore you can't call them.
Nevertheless MetadataSupport class is just a façade simplifying the usage of the metadata API and you can use the API directly. For example:
using Microsoft.Dynamics.ApplicationPlatform.Environment; using Microsoft.Dynamics.AX.Metadata.Storage; using Microsoft.Dynamics.AX.Metadata.Storage.Runtime; class Demo { public static void main(Args _args) { str packageDir = EnvironmentFactory::GetApplicationEnvironment().Aos.PackageDirectory; var runtimeProviderConfiguration = new RuntimeProviderConfiguration(packageDir); var provider = new MetadataProviderFactory().CreateRuntimeProvider(runtimeProviderConfiguration); var list = provider.DataEntityViewExtensions.ListObjectsForModel('MyModel'); } }
I've also noticed that one of the internal methods is used by DictDataEntity class, e.g. by getExtensionFieldNames(). It may be sufficient in some cases.
Bit old topic, but I'll try luck.
Looping through entities works fine.
But I don't see a method in MetadataSupport that would retrieve entity extensions.
There are corresponding methods for tables and classes ( Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetTableExtensionsForTable and ::GetFormExtensionNames ), but nothing for entities.
My aim is to list all entities we've extended.
I have found the answer, and this is my code. Thank you for helping me out.
static public void loopDataEntity()
{
var entityNames = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityViewNames();
var enumerator = entityNames.getEnumerator();
void loopFields()
{
AxDataEntityView axDataEntity;
axDataEntity = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityView(enumerator.Current);
var dataEntityFields = axDataEntity.Fields;
var defEnum = dataEntityFields.GetEnumerator();
while (defEnum.moveNext())
{
defEnum.moveNext();
info(strFmt("field - %1", defEnum.Current.ToString()));
}
} //end of method loopFields
;
while (enumerator.MoveNext())
{
enumerator.MoveNext();
info(strFmt("Data entity -- %1", enumerator.current));
loopFields();
}
}
Aha, so you know how to call GetDataEntityView() but you don't know what to do with the object.
Unfortunately I can't look at the code right now. I assume the class has a property called Fields or something and you can iterate it in the same way as I showed above with the list of entity names.
My environment doesn't have any data in that table either
I also need to loop through each of the Data Entity fields as well
How do I use the API similarly to reference the Data Entity fields?
Unfortunately my D365FO environment doesn't have any data in this table.
loop through table: DMFDefinitionGroupEntityXMLFields
MetadataSupport will help you with this part too:
var entityNames = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetDataEntityViewNames(); var enumerator = entityNames.GetEnumerator(); while (enumerator.MoveNext()) { info(enumerator.Current); }
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156