Avoid deleting a material in JobAssembly

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)
				MessageBox.Show("No puede elminiar");

@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.

Hi Greg, thanks for your idea, the problem is that the method that executes is the Update and it would block all that method.

that’s why I did it in the click event

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.

Throw exception with a message.

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 have not been successful, I apply the condition to the JobMtl table but it lets me delete.

this condition of RowMod = “D” must be by customcode?

I have not been successful, I apply the condition to the JobMtl table but it lets me delete.

This bpm works. It uses CheckBox20, so you will need to change to your custom field.

test stop delete.bpm (41.1 KB)

Friend, my problem is that the first condition is not validating it, the check condition does validate it

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.

1 Like