Validate checkbox en BPM JobAssembly

good afternoon,

create a new checkbox field in the jobAssembly / Subassemblies window, I want to create a BPM so that it does not allow adding matter if the check is True but I have not been able to since the ttJobAsmbl table is not taking the value that is in the database and the condition is always false, I am using a BPM with the GetNewJobMtl method.

In the database, the approved_esmb_c field has a value of 1 (true), but it is not validated in the BPM.


whats the “Guid” of your checkbox field?

this.epiCheckAprobado.Name = “epiCheckAprobado”;
this.epiCheckAprobado.EpiGuid = “7909df8c-6112-4c63-aab9-89b87cd35f4b”;

image

If you can use form customizations you can do this:

Create a before adapter method event using the form event wizard as ween here:

then Modify the event code to look at your checkbox before it proceeds. Does this work for you?

private void oTrans_jobAdapter_BeforeAdapterMethod(object sender, BeforeAdapterMethodArgs args)
{
// ** Argument Properties and Uses **
// ** args.MethodName **
// ** Add Event Handler Code **

	// ** Use MessageBox to find adapter method name
	EpiCheckBox checkBox = (EpiCheckBox)csm.GetNativeControlReference("f69b6575-a461-4c07-a660-bbabb7da63f5" /*INSERT YOUR GUID HERE INSTEAD OF MINE*/);
	bool checkBoxValue = checkBox.Checked;
	switch (args.MethodName)
	{
		case "GetNewJobMtl":
			 if (checkBoxValue == true)
			 {
			 	args.Cancel = true;
			 } else
			 {
			 	/*Do nothing*/
			 }
			break;
	}

}
1 Like

thank you for your nice help.

I did tests and the code works when adding materials to the parent Assembly, when I add a new subassemblies inside the parent assembly it allows me to add materials so this check is true


Are you saying when you add new subassemblies you also want that to stop you from adding new subassemblies?

is that it prevents adding materials if the check is approved, the idea is that many subassemblies can be made within the same parent assembly in the job and that when a subassembly has the approved check, materials cannot be included.

You need to use a dataview then, I have you checking a checkbox, but I think you need to use a dataview.

I’ll try to see if I can get you some code.

Friend, if you create a new subassembly and add a material in that subassembly, the method it calls is the same GetNewJobMtl I don’t understand why it doesn’t work if it’s the same from

Right, that’s what I saw too, so I am confused as well.

Can you put a message box and show the value of the checkbox to make sure it is actually true?

is taking it well

Bien, pero en ese ejemplo estas anadando el material en nivel 0 o en el subensamble? Lo que queiro ver es el valor cuando estas anadando el material en el subensamble.

that’s the problem that when I go to level 1 which is a subassembly and add material, the code doesn’t work. does nothing. it only works on the main Assembly. How could it be put into operation in the new subassemblies

Alberto… is the picture you last posted a picture of you adding a material to the subassembly 1 or subassembly 0?

in assembly 0 it works, it is parent, when I add new subassembly 1 and 2 like the picture, it doesn’t work

Can you show me the messagebox with the value of the checkbox when you are adding a material to subassembly 2? I would like to see this picture, but with the message box in front of it showing the value of the checkbox.

Utaylor, when I add material in subassembly 2 it doesn’t validate the code, it lets it save, I can’t show you a window.

Alberto,

EpiCheckBox checkBox = (EpiCheckBox)csm.GetNativeControlReference(“f69b6575-a461-4c07-a660-bbabb7da63f5” /INSERT YOUR GUID HERE INSTEAD OF MINE/);
bool checkBoxValue = checkBox.Checked;

	switch (args.MethodName)
	{
		case "GetNewJobMtl":

MessageBox.Show(checkBoxValue.ToString()); ADD THIS
// DialogResult dialogResult = EpiMessageBox.Show(“Cancel Update?”, “Cancel”, MessageBoxButtons.YesNo);
if (1==1)
{
args.Cancel = true;
MessageBox.Show(“Yup”);
} else
{
/**/
}
MessageBox.Show(“Test”);
break;
}

That’s what I am asking.

Can you put a message box outside of the IF statement, but below the case statement for GetNewJobMtl and see if it pops up?