Skip to content

Commit d417a58

Browse files
committed
First attempts at solving #10
1 parent 0e28e94 commit d417a58

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

CustomActionTester/CAT.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Rappen.XTB.CAT
99
{
1010
public partial class CustomActionTester : PluginControlBase
1111
{
12+
private InputValue inputdlg;
1213
#region Public Constructors
1314

1415
public CustomActionTester()
@@ -23,6 +24,11 @@ public CustomActionTester()
2324
public override void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName, object parameter)
2425
{
2526
base.UpdateConnection(newService, detail, actionName, parameter);
27+
inputdlg = null;
28+
cmbCustomActions.OrganizationService = null;
29+
cmbCustomActions.SelectedIndex = -1;
30+
gridInputParams.DataSource = null;
31+
gridOutputParams.DataSource = null;
2632
cmbCustomActions.OrganizationService = newService;
2733
txtUniqueName.OrganizationService = newService;
2834
txtUniqueName.OrganizationService = newService;
@@ -77,7 +83,11 @@ private void tslAbout_Click(object sender, EventArgs e)
7783

7884
private void gridInputParams_RecordDoubleClick(object sender, xrmtb.XrmToolBox.Controls.CRMRecordEventArgs e)
7985
{
80-
if (InputValue.ShowDialog(e.Entity, Service, this) == DialogResult.OK)
86+
if (inputdlg == null)
87+
{
88+
inputdlg = new InputValue(Service);
89+
}
90+
if (inputdlg.ShowDialog(e.Entity, this) == DialogResult.OK)
8191
{
8292
gridInputParams.Refresh();
8393
gridInputParams.AutoResizeColumns();

CustomActionTester/CATcode.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ private void GetCustomActions()
195195

196196
private void GetInputParams()
197197
{
198+
if (!(cmbCustomActions.SelectedEntity is Entity ca))
199+
{
200+
gridInputParams.DataSource = null;
201+
return;
202+
}
198203
var qx = new QueryExpression("sdkmessagerequestfield");
199204
qx.Distinct = true;
200205
qx.ColumnSet.AddColumns("name", "position", "optional", "parser", "fieldmask");
@@ -203,7 +208,7 @@ private void GetInputParams()
203208
var pair = req.AddLink("sdkmessagepair", "sdkmessagepairid", "sdkmessagepairid");
204209
var msg = pair.AddLink("sdkmessage", "sdkmessageid", "sdkmessageid");
205210
var wf = msg.AddLink("workflow", "sdkmessageid", "sdkmessageid");
206-
wf.LinkCriteria.AddCondition("workflowid", ConditionOperator.Equal, cmbCustomActions.SelectedEntity.Id);
211+
wf.LinkCriteria.AddCondition("workflowid", ConditionOperator.Equal, ca.Id);
207212
WorkAsync(new WorkAsyncInfo
208213
{
209214
Message = "Loading Input Parameters",
@@ -230,6 +235,11 @@ private void GetInputParams()
230235

231236
private void GetOutputParams()
232237
{
238+
if (!(cmbCustomActions.SelectedEntity is Entity ca))
239+
{
240+
gridOutputParams.DataSource = null;
241+
return;
242+
}
233243
var qx = new QueryExpression("sdkmessageresponsefield");
234244
qx.Distinct = true;
235245
qx.ColumnSet.AddColumns("name", "position", "parameterbindinginformation", "formatter", "publicname");
@@ -239,7 +249,7 @@ private void GetOutputParams()
239249
var pair = req.AddLink("sdkmessagepair", "sdkmessagepairid", "sdkmessagepairid");
240250
var msg = pair.AddLink("sdkmessage", "sdkmessageid", "sdkmessageid");
241251
var wf = msg.AddLink("workflow", "sdkmessageid", "sdkmessageid");
242-
wf.LinkCriteria.AddCondition("workflowid", ConditionOperator.Equal, cmbCustomActions.SelectedEntity.Id);
252+
wf.LinkCriteria.AddCondition("workflowid", ConditionOperator.Equal, ca.Id);
243253
WorkAsync(new WorkAsyncInfo
244254
{
245255
Message = "Loading Output Parameters",

0 commit comments

Comments
 (0)