Generating generate deep links for Dynamics 365 Finance and Operations (F&O).
Normally when a form is opened in F&O the form displays all records or applies some filter if a default view is applied. It doesn't drill down to a single record. But sometimes you need a URL link to drill down to a single record. E.g. a customer or vendor record. With deep links, you can drill down to a specific record in a form.
Unencrypted version of a deeplink:
https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&prt=initial&mi=display:CustTable&q={"Parameters":[{"DataSource":"CustTable","FieldValues":[{"Field":"AccountNum","Value":"US-002"}]}]}
When the system generates the deep link, it adds detailed query parameters to the URL. The datasource name, table field name and filter value are specfied for the form to filter on. If the form menu item has the right properties set, the result is that the form will recognize this and apply the filter automatically.
Encrypted version of a deeplink:
https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=usmf&prt=initial&mi=display:CustTable&q=BgAAAKtjn9amNj9Ibe1SID5uUafqfbbsq2Of1qY2P0ht7VIgPm5Rp%2bp9tuymMl72yjSV2bDEqxFBm%2blUyTB3uTX5155lA1AAn%2fzUohRn52fhmJ7y%2fy6kGLVzYTxMde0xqPliZnUU28hblRZ%2b4CxkpeT1576UN2n89XUANdpPxJ4H2mcc0O9WCOdpgtWGEr5nC8hHV%2bvV4u4Pj5DVhdrcWyg7ipSdPfVtNtPO2EmMf2nQQMTSePLlPvKJq8AlHqakLjdeN74lqUCxqroB8l0VgiXfYVvUe9NXs8hwnX6MrP2EAaUdd4dzE7DaNJNuxQnRXbu2BbO0QaUyBERPZ0IofUO3M8G5M9JpePw7nBMvBrCnixIGg4tZMAoPK0cjEAycIvYzG1A4be%2bhTWe1odR6WtnF4B3J8syydPbHUkIqWlnltkJCUToiQ4FiOfhScK%2bzHsyv2%2b8WLpLG2fxrIJGR5DrBusC6PLy%2bWHfZvvHQnUfMZnbqknj6%2b%2fG2qOcE%2fK%2fP%2baAkbfxDeaLTjrgHx2Sbe6KB4eKIi%2fA8bb8VidM29KkXkjXfAWRe%2b6D%2fognEL0kcy1nnYHZKs%2bOEl32ofeMT7REdfmSVLPP7tonH1NgKo7r%2fA9qIR%2b11%2bzbAXGfc0U76ZphIlylscjXMkZGceDK5%2b8mXgHFjF8vtamNaH1uH%2byONKCYsDCq4kI4W%2bfM7XvTulFVWq7hWJb2hnPAsCkdJuWKdgWbgOs4ACSQvH3f63ZQtysryLH0yAsa8TQdmXYJ610xmskt0a6K4hC7ZHFHdfGPYyICwSza7wDH6mZJuWlnkdSKQVixmCV1HRkyjkVTg5fYTXZyfeWGHVpwf%2bBC3%2fp7NyD7wFsvP3im6S1Cdgu5eLIwVKRlZyaSj37SoylD5XwPQmmQXURi54I2f
Note the length of this URL is 1063 characters!
Notes:
- The deep link URL created by the system is very long and does not fit in the URL EDT because its max length is just 255.
- The menu item used must have the following properties enabled:
- Allow root navigation = Yes
- Copy caller query = Yes
- The UrlUtility::getUrl() function does not work in batch. Do a search on how to get the system URL in batch.
- Only use unencrypted deeplinks for testing as they do not work.
Full code example
public class MyDeepLinkTest
{
public static str createDeepLinkUrl(MenuItemName _menuItemName, DataSourceName _keyFilterDataSourceName, FieldName _keyFilterFieldName, str _keyFilterFieldValue)
{
var generator = new Microsoft.Dynamics.AX.Framework.Utilities.UrlHelper.UrlGenerator();
var currentHost = new System.Uri(UrlUtility::getUrl());
generator.HostUrl = currentHost.GetLeftPart(System.UriPartial::Authority);
generator.Company = curext();
generator.MenuItemName = _menuItemName;
generator.MenuItemType = MenuItemType::Display; //avent: display only.
generator.Partition = getCurrentPartition();
generator.EncryptRequestQuery = true; //avent: set to false for testing only.
//repeat for each datasource to filter
var requestQueryParameterCollection = generator.RequestQueryParameterCollection;
requestQueryParameterCollection.AddRequestQueryParameter(_keyFilterDataSourceName, _keyFilterFieldName, _keyFilterFieldValue);
System.Uri fullURI = generator.GenerateFullUrl();
return fullURI.AbsoluteUri; //to get the encoded URI
}
public static void main(Args _args)
{
str link = MyDeepLinkTest::createDeepLinkUrl(menuItemDisplayStr(CustTable),
formDataSourceStr(CustTable, CustTable),
fieldstr(CustTable, AccountNum),
"US-002");
Dialog dlg = new Dialog();
dlg.addField(extendedTypeStr(Notes)).value(link);
dlg.run();
}
}
Result of running the above code
No comments:
Post a Comment