04.11.2016, 00:11 | #1 |
Участник
|
goshoom: New metadata API
Источник: http://dev.goshoom.net/en/2016/11/new-metadata-api/
============== AX 7 (“Microsoft Dynamics 365 for Operations”) offers a new API for getting metadata of AX elements such as tables, form extensions, models and so on. It’s very easy to use, therefore even if you’re very familiar with the old TreeNode API, you should definitely pay attention to this new one. The best place to start is in the MetadataSupport class in Microsoft.Dynamics.Ax.Xpp namespace (yes, the whole API is in an external library; it’s not written in X++). The class offers many static methods providing information about elements. Taking tables as an example, you can use:
Element details are represented by classes with names prefixed with Ax. For example, GetTable() returns an instance of AxTable class. (All these classes are defined in another assembly; the namespace is Microsoft.Dynamics.AX.Metadata.MetaModel). These classes provide all details you may need. For tables, you can see properties, fields, indexes, methods and everything else. Let me give you a full example that you can take and run in your environment. It iterates all controls in a given form and put their names to infolog. X++: using Microsoft.Dynamics.AX.Metadata.MetaModel; class MetadataDemo { public static void main(Args _args) { AxForm form = Microsoft.Dynamics.Ax.Xpp.MetadataSupport::GetForm(formStr(SysUserSetup)); new MetadataDemo().showControlNames(form.Design); } private void showControlNames(IFormControlCollection _control) { var controlEnumerator = _control.Controls.GetEnumerator(); while (controlEnumerator.MoveNext()) { AxFormControl control = controlEnumerator.Current; if (control is IFormControlCollection) { this.showControlNames(control as IFormControlCollection); // Recursion } else { info(control.Name); } } } } There are a few things to notice:
Источник: http://dev.goshoom.net/en/2016/11/new-metadata-api/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось mazzy; 04.11.2016 в 08:20. |
|
|
|