The URL Generator must be used from code running on the AOS, in an active user session or batch process. This requirement ensures that the URL can be secured through encryption specific to the instance that generates the URL. At a minimum, the following information must be specified and passed to the URL Generator in order to generate a working URL.
- Host URL
- The URL of the web root for the instance. For example:
https://ax.dynamics.contoso.com/
- The URL of the web root for the instance. For example:
- AOT name of the Menu Item Display
- The menu item display to be used to open the form.
- Partition
- The partition to use for the request.
- Company
- The company to use for the request.
// gets the generator instance
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 = <menu item name>;
generator.Partition = getCurrentPartition();
// repeat this segment for each datasource to filter
var requestQueryParameterCollection = generator.RequestQueryParameterCollection;
requestQueryParameterCollection.AddRequestQueryParameter(
<datasource name>,
<field1>, <value1>,
<field2>, <value2>,
<field3>, <value3>,
<field4>, <value4>,
<field5>, <value5>
);
System.Uri fullURI = generator.GenerateFullUrl();
// to get the encoded URI, use the following code
fullURI.AbsoluteUri
Source: Create shareable, secured URLs (deep links) - Finance & Operations | Dynamics 365 | Microsoft Docs
No comments:
Post a Comment