The following code is to generate the deep link URL to open the specific records in D365
using Microsoft.Dynamics.AX.Framework.Utilities;
class Dal_URLGeneration
{
private static str buildAXURL(MenuItemName _menuItemName, MenuItemType _menuItemtype, DataSourceName _dataSource='', FieldName _field='', str _value='' )
{
UrlHelper.UrlGenerator generator = new UrlHelper.UrlGenerator();
System.Uri currentHost = new System.Uri(UrlUtility::getUrl());
generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);
generator.Company = curExt();
generator.MenuItemName = _menuItemName;
generator.MenuItemType = _menuItemtype;
generator.Partition = getCurrentPartition();
generator.EncryptRequestQuery = true;
if(_dataSource != '')
{
UrlHelper.RequestQueryParameterCollection requestQueryParameterCollection;
requestQueryParameterCollection = generator.RequestQueryParameterCollection;
requestQueryParameterCollection.AddRequestQueryParameter(_dataSource, _field, _value);
}
System.Uri fullURI = generator.GenerateFullUrl();
return fullURI.AbsoluteUri;
}
public static void main(Args _args)
{
str link;
link = Dal_URLGeneration::buildAXURL(menuItemDisplayStr(CustTable), MenuItemType::Display, formDataSourceStr(CustTable,CustTable), fieldstr(CustTable, AccountNum), "1005" );
info(link);
}
}
Note: Change the Property of the display menu item -- Copy caller query --- Yes
using Microsoft.Dynamics.AX.Framework.Utilities;
class Dal_URLGeneration
{
private static str buildAXURL(MenuItemName _menuItemName, MenuItemType _menuItemtype, DataSourceName _dataSource='', FieldName _field='', str _value='' )
{
UrlHelper.UrlGenerator generator = new UrlHelper.UrlGenerator();
System.Uri currentHost = new System.Uri(UrlUtility::getUrl());
generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);
generator.Company = curExt();
generator.MenuItemName = _menuItemName;
generator.MenuItemType = _menuItemtype;
generator.Partition = getCurrentPartition();
generator.EncryptRequestQuery = true;
if(_dataSource != '')
{
UrlHelper.RequestQueryParameterCollection requestQueryParameterCollection;
requestQueryParameterCollection = generator.RequestQueryParameterCollection;
requestQueryParameterCollection.AddRequestQueryParameter(_dataSource, _field, _value);
}
System.Uri fullURI = generator.GenerateFullUrl();
return fullURI.AbsoluteUri;
}
public static void main(Args _args)
{
str link;
link = Dal_URLGeneration::buildAXURL(menuItemDisplayStr(CustTable), MenuItemType::Display, formDataSourceStr(CustTable,CustTable), fieldstr(CustTable, AccountNum), "1005" );
info(link);
}
}
Note: Change the Property of the display menu item -- Copy caller query --- Yes