Skip to content

Instantly share code, notes, and snippets.

@FH-Inway
Forked from noakesey/Formrun_Class_Extension.xpp
Created February 15, 2022 20:00
Show Gist options
  • Save FH-Inway/e96fe0350cc989526f34c9ee85fbd621 to your computer and use it in GitHub Desktop.
Save FH-Inway/e96fe0350cc989526f34c9ee85fbd621 to your computer and use it in GitHub Desktop.
[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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment