Skip to content

Instantly share code, notes, and snippets.

@mazzy-ax
Last active Oct 9, 2020
Embed
What would you like to do?
getTables. X++ for Microsoft Dynamics AX7
class getTables
{
public static void Main(Args _args)
{
str packageDir = 'C:\AOSService\PackagesLocalDirectory';
//or
var environment = Microsoft.Dynamics.ApplicationPlatform.Environment.EnvironmentFactory::GetApplicationEnvironment();
packageDir = environment.get_Aos().get_PackageDirectory();
// it's kind of magic
var runtimeProviderConfiguration = New Microsoft.Dynamics.AX.Metadata.Storage.Runtime.RuntimeProviderConfiguration(packageDir);
var metadataProviderFactory = New Microsoft.Dynamics.AX.Metadata.Storage.MetadataProviderFactory();
Microsoft.Dynamics.AX.Metadata.Providers.IMetadataProvider provider = metadataProviderFactory.CreateRuntimeProvider(runtimeProviderConfiguration);
// object names
print provider.Tables.ListObjectsForModel('FleetManagement');
print provider.Tables.ListObjectsForModel('FleetManagementExtension');
print provider.TableExtensions.ListObjectsForModel('FleetManagement');
print provider.TableExtensions.ListObjectsForModel('FleetManagementExtension');
// single object by name
Microsoft.Dynamics.AX.Metadata.MetaModel.AxTable custTransMetaData = provider.Tables.Read('CustTrans');
Microsoft.Dynamics.AX.Metadata.MetaModel.AxClass c = provider.Classes.Read('LedgerVoucher');
}
}
@AdnanePow

This comment has been minimized.

Copy link

@AdnanePow AdnanePow commented Dec 27, 2019

Hi @mazzy-ax , thanks for this very helpful post
in your example showed only 1 table passed as paramter ?

var = oneExtendedMenu = provider.MenuExtension.read("NameOfExtendedMenu");

What if i want to iterate all Menu extensions, and not only ?
var extendedMenus = provider.MenuExtensions;
how can i iterate the "ExtendedMenus" and get the current AxMenuExtension

Can you help on this please, thanks ?

@mazzy-ax

This comment has been minimized.

Copy link
Owner Author

@mazzy-ax mazzy-ax commented Dec 27, 2019

Hi @AdnanePow

Good question. I don't know. Sorry

@AdnanePow

This comment has been minimized.

Copy link

@AdnanePow AdnanePow commented Dec 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment