I have a job in which there are two subAssemblyes and I want to prevent them from deleting the materials if the check is approved in a customization that makes this true.
I already have the following code that works to a certain extent, it does the validation but at the time of canceling the operation it does not.
When it reaches this if
if (bool.Parse(CurrAsm_Row.dataView[CurrAsm_Row.dataView.Count - 1]["aprobado_asmb_c"].ToString())== true)**
** {**
** args.Tool.Dispose();**
** MessageBox.Show("No puede elminiar");
it does not finish the operation and lets me delete
it sends me the message but this code does not execute it “args.Tool.Dispose();”
this is the codigo
private void JobEntryForm_BeforeToolClick(object sender, Ice.Lib.Framework.BeforeToolClickEventArgs args)
{
switch (args.Tool.Key)
{
case "DeleteTool":
if (this.CurrAsm_Row.HasRow)
{
//MessageBox.Show (CurrAsm_Row.dataView[CurrAsm_Row.dataView.Count - 1]["aprobado_asmb_c"].ToString());
if (bool.Parse(CurrAsm_Row.dataView[CurrAsm_Row.dataView.Count - 1]["aprobado_asmb_c"].ToString())== true)
{
args.Tool.Dispose();
MessageBox.Show("No puede elminiar");
}
}
break;
}
@atorres I would try to do this in a preprocessing bpm rather than a customization. Do a tracing and see what is called before the update so you can stop it before it begins that transaction if possible. Even those are sometimes not stoppable.
Also since customizations are going to go away this would be a better solution going forward.
you would use the same conditions. I have several like this on Jobentry update.
Condition There is at least one deleted row in JobMtl and aprobado_asmb_c equals True.
You should still be able to validate it in the update method… you can check for the RowMod = “D” (deleted)… and if they it is D, and if the checkbox is true, then throw an error.
BPM is the best way to do this.
I don’t think ttJobAsmbl is going to exist in a delete transaction of JobMtl. Use a query to get the value from JobAsmbl like I checked for CheckBox20 from JobHead.