Skip to content

Instantly share code, notes, and snippets.

@fedejousset
fedejousset / getParam.html
Last active May 16, 2018 10:41
Example HTML based on MSFT documentation on how to get custom parameters passed to a WebResource - TESTED IN v9
<!DOCTYPE html >
<html lang="en-us">
<head>
<title>Show D365 v9 Parameters Page</title>
<script>
document.onreadystatechange = function () {
if (document.readyState == "complete") {
getDataParam();
}
}
public class PublishPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.MessageName != "Publish" && context.MessageName != "PublishAll")
return;
SELECT DISTINCT
'InputParameter',
REPLACE(mreq.Name, '{Entity.PrimaryEntityName}', ''),
mrf.Name,
CASE
WHEN CHARINDEX(',', mrf.ClrParser) > 0 THEN SUBSTRING(mrf.ClrParser, 1, CHARINDEX(',', mrf.ClrParser) - 1)
ELSE mrf.ClrParser
END,
CASE
WHEN mrf.Optional is null THEN 1