Skip to content

Instantly share code, notes, and snippets.

@noakesey
Created February 15, 2022 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noakesey/789923163534001e5228870caee005d4 to your computer and use it in GitHub Desktop.
Save noakesey/789923163534001e5228870caee005d4 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