How to modify on the fly the results returned following a query from a FetchXML Report
-
sexta-feira, 18 de maio de 2012 22:34
Hi,
While running a FetchXML report, I am trying to modify on the fly the results returned as a result of the report's FetchXML query
I have a FecthXML report. I created a RetrieveMultiple event that hooks to any entity being queried.
While debugging, when running the report, the Execute of the RetrieveMultiple event method never gets fired.
I then created a step that subscribe to the Execute message of ANY entity. When running the report, the execute method is fired.
But when I modify the results of the query in the execute method of the plugin that triggers in a post operation, nothing happens. So setting the context's OutputParameters does not work : context.OutputParameters["FetchXmlResult"] = someModifiedResults
When I check the results in the OutputParameters at the end of the Execute method of the plugin, they are set to the new provided results. But when my report effectively shows, it only shows the original non modified results. How can I modify the results in the post operation so that they appear in the report being run?
Here is some code you can use for the Execute method, of the plugin. Remember, the plugin is registered for any Execute message on any entity.
I fire the Execute method by running any FecthXML based Report.
public override void Execute(IExecutionContext context, IOrganizationService service, ITracingService tracingService)
{
if (context.Depth != 1)
return;
if (context.MessageName == "Execute" && context.InputParameters.Contains("FetchXml"))
{
XmlDocument outdoc = new XmlDocument();
outdoc.LoadXml((string)context.OutputParameters["FetchXmlResult"]);
// Let's say I wanna Remove all the results
// i am expecting my Report to be empty!!
outdoc.SelectSingleNode("//resultset").RemoveAll();
context.OutputParameters["FetchXmlResult"] = outdoc.OuterXml;
}
}Hope somebody have an answer for this!
Todas as Respostas
-
terça-feira, 22 de maio de 2012 17:49
Seems that reports do not trigger plugins. What fires the Execute method is something else, not the query itself!!!
It seems that the execute is fired when reports are trying to get the filters defined by the user.
- Marcado como Resposta Zouma terça-feira, 22 de maio de 2012 17:49