02.11.2017, 18:11 | #1 |
Участник
|
thwidmer: Deep links available in every form
Источник: https://thwidmer.wordpress.com/2017/...in-every-form/
============== Ievgen Miroshnikov gave me the idea and Microsoft also has some information here. The following extends the standard button available in every Dynamics 365 for Finance and Operations form to provide the deep link to the currently select record of the primary form data source. Copy the link and share it. The recipient will jump directly to the currently selected record. (I wonder why Microsoft doesn’t provide this in standard D365FO – this is actually what you would expect from the button.) X++: using Microsoft.Dynamics.AX.Framework.Utilities; using Microsoft.Dynamics.@Client.ServerForm.Contexts; /// <summary> /// The class <c>URLUtility_Extension</c> contains extension methods for the <c>URLUtility</c> class. /// </summary> [ExtensionOf(classStr(URLUtility))] public static class URLUtility_Extension { public static str generateRecordUrl(str _menuItemName, MenuItemType _menuItemType, DataSourceName _dataSourceName, Map _indexFieldValuesMap, DataAreaId _dataAreaId = curExt()) { System.Uri host = SessionContext::Get_Current().Get_RequestUrl(); UrlHelper.UrlGenerator generator = new UrlHelper.UrlGenerator(); generator.MenuItemName = _menuItemName; generator.MenuItemType = _menuItemType; generator.HostUrl = host.GetLeftPart(System.UriPartial::Path); generator.Company = _dataAreaId; generator.EncryptRequestQuery = true; if (_dataSourceName && _indexFieldValuesMap) { MapEnumerator mapEnumerator = _indexFieldValuesMap.getEnumerator(); var requestQueryParameterCollection = generator.RequestQueryParameterCollection; while (mapEnumerator.moveNext()) { requestQueryParameterCollection.UpdateOrAddEntry(_dataSourceName, mapEnumerator.currentKey(), mapEnumerator.currentValue()); } } return generator.GenerateFullUrl().AbsoluteUri; } public static str generateRecordUrlFromDataSource(FormDataSource _formDataSource) { FormRun formRun = _formDataSource.formRun(); str menuItemName = formRun.args().menuItemName(); MenuItemType menuItemType = formRun.args().menuItemType(); DataSourceName dataSourceName = _formDataSource.name(); TableId tableId = _formDataSource.table(); DictTable dictTable = new DictTable(tableId); DictIndex dictIndex = new DictIndex(tableId, dictTable.primaryIndex()); int fieldCount = dictIndex.numberOfFields(); Map indexFieldValuesMap = new Map(Types::String, Types::String); Common record = _formDataSource.cursor(); FieldId primaryKeyFieldId; for (int fieldIndex = 1; fieldIndex <= fieldCount; fieldIndex++) { primaryKeyFieldId = dictIndex.field(fieldIndex); indexFieldValuesMap.insert(fieldId2Name(tableId, primaryKeyFieldId), any2Str(record.(primaryKeyFieldId))); } return URLUtility::generateRecordUrl(menuItemName, menuItemType, dataSourceName, indexFieldValuesMap, record.DataAreaId); } public static str generateUrl(FormRun formRun) { str url = next generateUrl(formRun); if (formRun && formRun.dataSource(1) && formRun.dataSource(1).cursor()) { url = URLUtility::generateRecordUrlFromDataSource(formRun.dataSource(1)); } return url; } }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. Последний раз редактировалось mazzy; 03.11.2017 в 00:41. |
|