Navigating to a D365FO entity without a deep link

It’s possible to create shareable, secured URLs (deep links) using the Get a link menu available in most forms.

The generated link will have an encrypted encoding of the filters to apply to the target form in the q parameter, e.g.

mi=CustTableListPage&q=BgAAADbAgcy%2BwgQAas23344234234%2FImzylNTQAV1dbeiN76NV0fV43AvCzbEqcLzYfiiWmjrcDJ65pmHbliJ66Q%2zdH35JJGnncehrxnW09b6vElH…

However, since the filters are encrypted, it isn’t possible to generate a deep link outside of D365FO.

If you have an internal application that holds the primary key of an entity (e.g. the AccountNum of a Customer or Vendor), it can be a challenge to navigate your users to D365FO without either setting up an integration to generate and persist the deep links for each entity or provide a deep link lookup service.

It would be far easier if we could navigate directly and so long as we are comfortable with the security implications of embedding unencrypted filters within query strings, we can make this happen by creating a Chain of Command extension for the FormRun class:

[ExtensionOf(classStr(FormRun))]
public final class FormRun_Class_Extension
{
/// <summary>
/// This allows unencrypted setting of the recordContext via the q querystring parameter:
/// q={"Parameters":[{"DataSource":"CustTable","FieldValues":[{"Field":"AccountNum","Value":"C123456789"}]}]}
/// </summary>
/// <param name = "_recordContext"></param>
/// <returns></returns>
public boolean applyRecordContext(str _recordContext)
{
str recordContext = _recordContext;
//Basic check for JSON in the recordContext is assumed to be an unencrypted requestQueryParameter
if (strStartsWith(recordContext, '{') && strEndsWith(recordContext, '}') && strContains(recordContext, ':'))
{
var generator = new Microsoft.Dynamics.AX.Framework.Utilities.UrlHelper.UrlGenerator();
generator.EncryptRequestQuery = false;
generator.ParseRequestQueryParameter(_recordContext);
//Encrypt the requestQueryParameter and pass it on
generator.EncryptRequestQuery = true;
recordContext = generator.GenerateRequestQueryString();
}
return next applyRecordContext(recordContext);
}
}

This allows us to also use the unencrypted format for internal navigation:

mi=CustTableListPage&q={“Parameters”:[{“DataSource”:”CustTable”,”FieldValues”:[{“Field”:”AccountNum”,”Value”:”C1234567890″}]}]}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: