Skip to content

Commit

Permalink
Implemented integration param view:<guid> Closed #884
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Aug 8, 2023
1 parent a238809 commit 0690d1c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
24 changes: 19 additions & 5 deletions FetchXmlBuilder/FXBInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void OnIncomingMessage(MessageBusEventArgs message)

callerArgs = message;
var fetchXml = string.Empty;
var layoutxml = string.Empty;
var requestedType = "FetchXML";
if (message.TargetArgument != null)
{
Expand All @@ -59,20 +60,33 @@ public void OnIncomingMessage(MessageBusEventArgs message)
fetchXml = fxbArg.FetchXML;
requestedType = fxbArg.Request.ToString();
}
else if (message.TargetArgument is string)
else if (message.TargetArgument is string strArgument)
{
fetchXml = (string)message.TargetArgument;
if (strArgument.ToLowerInvariant().StartsWith("view:"))
{
if (!Guid.TryParse(strArgument.Split(':')[1], out Guid id))
{
MessageBox.Show($"Incorrect Guid: {strArgument}", "Loading Views", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
View = GetViewById(id);
fetchXml = View?.GetAttributeValue<string>("fetchxml");
layoutxml = View?.GetAttributeValue<string>("layoutxml");
}
else
{
fetchXml = strArgument;
}
}
}
dockControlBuilder.ParseXML(fetchXml, false);
UpdateLiveXML();
dockControlBuilder.Init(fetchXml, layoutxml, $"called from {message.SourcePlugin}", false);
attributesChecksum = dockControlBuilder.GetAttributesSignature();
tsbReturnToCaller.Text = callerArgs.SourcePlugin == URLcaller ? "FetchXML from an URL" : "Return FetchXML";
tsbReturnToCaller.Image =
callerArgs.SourcePlugin == "Bulk Data Updater" ? Cinteros.Xrm.FetchXmlBuilder.Properties.Resources.BDU_2019_032_tsp :
callerArgs.SourcePlugin == URLcaller ? Cinteros.Xrm.FetchXmlBuilder.Properties.Resources.icon_web :
Cinteros.Xrm.FetchXmlBuilder.Properties.Resources.icon_return;
tsbReturnToCaller.ToolTipText = callerArgs.SourcePlugin == URLcaller ? "Show 'Sharing Queries' on my website." : "Return " + requestedType + " to " + callerArgs.SourcePlugin;
dockControlBuilder.RecordHistory("called from " + message.SourcePlugin);
LogUse("CalledBy." + callerArgs.SourcePlugin);
if (callerArgs.SourcePlugin == "View Designer" && !connectionsettings.TipsAgainstOrViewDesignerToolShown)
{
Expand Down
26 changes: 26 additions & 0 deletions FetchXmlBuilder/FXBQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Rappen.XTB.FetchXmlBuilder.Settings;
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Windows.Forms;
using System.Xml;
using XrmToolBox.Extensibility;
Expand Down Expand Up @@ -178,6 +179,31 @@ internal void LoadViews(Action viewsLoaded)
});
}

internal Entity GetViewById(Guid id)
{
var cols = new ColumnSet("name", "returnedtypecode", "fetchxml", "layoutxml");
try
{
return Service.Retrieve("savedquery", id, cols);
}
catch (FaultException<OrganizationServiceFault>)
{
try
{
return Service.Retrieve("userquery", id, cols);
}
catch (FaultException<OrganizationServiceFault>)
{
MessageBox.Show($"Cannot find either a system's or a personal's view with id {id}.", "Loading View", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
ShowErrorDialog(ex);
}
}
return null;
}

internal void StringQueryExpressionToFetchXml(string query, QExStyleEnum style)
{
working = true;
Expand Down

0 comments on commit 0690d1c

Please sign in to comment.