Skip to content

Commit 36b5b4f

Browse files
committed
Added dialog for input param values
1 parent 60fe645 commit 36b5b4f

File tree

8 files changed

+643
-165
lines changed

8 files changed

+643
-165
lines changed

CustomActionTester/CAT.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.Xrm.Sdk;
33
using System;
44
using System.Linq;
5+
using System.Windows.Forms;
56
using XrmToolBox.Extensibility;
67

78
namespace Rappen.XTB.CAT
@@ -44,16 +45,6 @@ private void btnExecute_Click(object sender, EventArgs e)
4445
ExecuteCA();
4546
}
4647

47-
private void btnSaveInputParamValue_Click(object sender, EventArgs e)
48-
{
49-
if (gridInputParams.SelectedCellRecords.FirstOrDefault() is Entity input)
50-
{
51-
input["value"] = txtInputParamValue.Text;
52-
gridInputParams.Refresh();
53-
gridInputParams.AutoResizeColumns();
54-
}
55-
}
56-
5748
private void cmbCustomActions_SelectedIndexChanged(object sender, EventArgs e)
5849
{
5950
txtUniqueName.Entity = cmbCustomActions.SelectedEntity;
@@ -67,12 +58,6 @@ private void CustomActionTester_Load(object sender, EventArgs e)
6758
LogUse("Load");
6859
}
6960

70-
private void gridInputParams_RecordEnter(object sender, xrmtb.XrmToolBox.Controls.CRMRecordEventArgs e)
71-
{
72-
e.Entity.TryGetAttributeValue("value", out string value);
73-
txtInputParamValue.Text = value;
74-
}
75-
7661
private void gridOutputParams_RecordClick(object sender, xrmtb.XrmToolBox.Controls.CRMRecordEventArgs e)
7762
{
7863
txtResultDetail.Text = FormatResultDetail();
@@ -89,5 +74,14 @@ private void tslAbout_Click(object sender, EventArgs e)
8974
}
9075

9176
#endregion Private Methods
77+
78+
private void gridInputParams_RecordDoubleClick(object sender, xrmtb.XrmToolBox.Controls.CRMRecordEventArgs e)
79+
{
80+
if (InputValue.ShowDialog(e.Entity, Service, this) == DialogResult.OK)
81+
{
82+
gridInputParams.Refresh();
83+
gridInputParams.AutoResizeColumns();
84+
}
85+
}
9286
}
9387
}

CustomActionTester/CAT.designer.cs

Lines changed: 104 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CustomActionTester/CAT.resx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,6 @@
180180
<metadata name="value.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
181181
<value>True</value>
182182
</metadata>
183-
<data name="btnSaveInputParamValue.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
184-
<value>
185-
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAK
186-
8AAACvABQqw0mAAAAAd0SU1FB9YFFw0xLYbHfVAAAAHjSURBVDhPpZPdS1NhHMe/Z7OjYzKUuTdam6Qy
187-
ddO2GrG6iDLywjD0pq419coLDZQuxLyLwNVSqosueoeCCneGFTbwRmq4iogI/4X1B/Siwq/vc/RYFxor
188-
v/C5eX7P5/e8nYP/iLbJP+YGgtosinqm4hPO4QRHqkmZjR7Cb7+prVx8PySd+VaxTeILR48Qp1n/ax7B
189-
i1l8HisOSCLrkXjOKxVTthIrIyRozmn4UHMgZFT3Yq/Z0W4OqtyBW5vBxwvL5yn7pC1XJ45p/RtCuMfq
190-
OAmhYd41dHbp5PqZ/GGpvMX1gDDRcRe1uI53lhzLUk7r37Ef91mfJqeICymjuTRY6JDO12GJ5TyCSTxB
191-
M+LIoDBa6KMckJjhFmda/0H5AaU06SIeYoPntnP+2MuwdCzUy/FXYWl8XCvaFe3r6Nt+OWgEJJqlfE3/
192-
iSZTvkpOEy/ZPGqCW76MN4c4+eiLoCRzfunOJyU+55PWOVNeRWRL7iY+8vuemEpuLYkpFNqfeyVhUHxW
193-
Jy1q5Yy+higfETzQDrIVB+qRwgSKkaduifIuXDOUY1tyD/GTbWUV9UU5+CgpDGNxzyV7iSur27bkANlR
194-
trLRBGgng2SMqAsrS7aimlQRtd19pIaULf8Z1ajMH2VXAX4BPIuP4uqOByUAAAAASUVORK5CYII=
195-
</value>
196-
</data>
197183
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
198184
<value>True</value>
199185
</metadata>

CustomActionTester/CATcode.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@ private void ExecuteCA()
6060
var request = new OrganizationRequest(txtMessageName.Text);
6161
foreach (var input in gridInputParams.DataSource as IEnumerable<Entity>)
6262
{
63-
if (input.TryGetAttributeValue("name", out string name) &&
64-
input.TryGetAttributeValue("value", out string value))
63+
if (input.TryGetAttributeValue("name", out string name))
6564
{
66-
request[name] = value;
65+
if (input.TryGetAttributeValue("rawvalue", out object value))
66+
{
67+
request[name] = value;
68+
}
69+
else if (input.TryGetAttributeValue("optional", out bool optional) && !optional)
70+
{
71+
MessageBox.Show($"Missing value for required parameter: {name}", "Execute Custom Action", MessageBoxButtons.OK, MessageBoxIcon.Warning);
72+
return;
73+
}
6774
}
6875
}
6976
WorkAsync(new WorkAsyncInfo

CustomActionTester/CustomActionTester.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
<Compile Include="CAT.designer.cs">
189189
<DependentUpon>CAT.cs</DependentUpon>
190190
</Compile>
191+
<Compile Include="InputValue.cs">
192+
<SubType>Form</SubType>
193+
</Compile>
194+
<Compile Include="InputValue.Designer.cs">
195+
<DependentUpon>InputValue.cs</DependentUpon>
196+
</Compile>
191197
<Compile Include="Properties\AssemblyInfo.cs" />
192198
</ItemGroup>
193199
<ItemGroup>
@@ -201,6 +207,9 @@
201207
<EmbeddedResource Include="CAT.resx">
202208
<DependentUpon>CAT.cs</DependentUpon>
203209
</EmbeddedResource>
210+
<EmbeddedResource Include="InputValue.resx">
211+
<DependentUpon>InputValue.cs</DependentUpon>
212+
</EmbeddedResource>
204213
</ItemGroup>
205214
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
206215
<PropertyGroup>

CustomActionTester/InputValue.Designer.cs

Lines changed: 261 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)