How to reference a form checkbox in a BPM

In the MES End Labor Activity form , I want to write a BPM to check that all the previous operations for a job have marked completed when the user click on the Complete check box - method is Erp.Labor.EndActivityComplete. How do I reference the chkComplete to uncheck it if there exist some previous operations that have not been marked completed.

hi @Lee,
-in my opinion- i do not think that you need to check all previous operations you only need to check the last previous operation, and there is a standard shop warning you can set, to alert operators (labors) and send emails, however if you need to stop the labour transaction then pre-process BPM on EndActivity adding a custom code (foreach loop) to find and validate the last previous operation and raise an exception.

Edit:
the more logical place is StartActivity Not EndActivity

Hi @A.Baeisa, thanks for your reply. I have the pre preprocessing code

Erp.Tables.JobOper JobOper;

callContextBpmData.Character01 = string.Empty;

var jobRow = (from JobOper_Row in Db.JobOper where JobOper_Row.Company == Session.CompanyID && JobOper_Row.JobNum == callContextBpmData.Character02 && JobOper_Row.OpComplete == false && JobOper_Row.OprSeq < callContextBpmData.Number02
select JobOper_Row).FirstOrDefault();

if (jobRow != null)
{
callContextBpmData.Character01 = jobRow.OpCode.ToString();
callContextBpmData.Number01 = jobRow.OprSeq;
callContextBpmData.Character10=“NOK”;
// callContextBpmData.Character19 = orderRow.OpComplete;
}
else
{
callContextBpmData.Character01=“OK”;
}

and in the exception I check for Character01=“NOK”. It worked but the chkComplete check box in the End Job Activity is still checked and the user can still click OK and it will marked the operation completed even though the previous has not. I need to uncheck the chkComplete check box so that if the user click Ok, it will not be marked completed.

Hi @Lee,
i see what you mean, i.e. at Start Activity method the Job Oper record is not yet loaded, so the easiest and correct way -in my opinion- is to trigger a BPMCallContext variable at Post-Process StartActivity then capture it at the Pre-Process Update method, so my design will stop any one to login on any operation as long as its previous operation has not been completed, Note: this solution will not correct history but going forward each start operation will validate previous one i.e. no operation can be missed, so

  1. Trigger a BPMCallContext variable at Post-Process StartActivity method:

2.Do the validation at Pre-Process LaborDtl Update method:

the code i created:

int iPreviousJobOperOprSeq = 0;
var ttLaborDtl_xRow = (from ttLaborDtl_Row in ttLaborDtl
										where ttLaborDtl_Row.Company == Session.CompanyID			
			select ttLaborDtl_Row).FirstOrDefault();

if(ttLaborDtl_xRow != null)
{

int[] list = (from JobOper_Row in Db.JobOper
where JobOper_Row.Company == Session.CompanyID
&& JobOper_Row.JobNum == ttLaborDtl_xRow.JobNum
&& JobOper_Row.OprSeq < ttLaborDtl_xRow.OprSeq
select JobOper_Row.OprSeq).ToArray();

	if(list !=null && list.Length > 0)
	{
	
	iPreviousJobOperOprSeq=list.Max();
	var JobOper = (from JobOper_Row in Db.JobOper
	where JobOper_Row.Company == Session.CompanyID
	&& JobOper_Row.JobNum == ttLaborDtl_xRow.JobNum
	&& JobOper_Row.OprSeq == iPreviousJobOperOprSeq
	&& JobOper_Row.OpComplete == false
	select JobOper_Row).FirstOrDefault();
		if(JobOper != null)
		{
	CallContext.Current.ExceptionManager.AddBLException("Previous Job Operation Sequence : "+iPreviousJobOperOprSeq+" is incomplete please correct to proceed");
		}
	}
}


HTH

Hi I am doing the same operation but I want to call BPM when the chkcomplete checkbox is checked. I am struggling at the first step on how to add event to checkbox when it is checked.
I am getting this error
**
Error: CS1061 - line 68 (1699) - ‘Script’ does not contain a definition for ‘chkComplete’ and no extension method ‘chkComplete’ accepting a first argument of type ‘Script’ could be found (are you missing a using directive or an assembly reference?)**

This is my code:

Blockquote
private void chkComplete_CheckedChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
MessageBox.Show(“You are in the CheckBox.CheckedChanged event.”);
}
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete ‘Begin/End Wizard Added Variable Initialization’ lines **
// Begin Wizard Added Variable Initialization
this.edvLPart = ((EpiDataView)(this.oTrans.EpiDataViews[“LPart”]));
this.edvEnd = ((EpiDataView)(this.oTrans.EpiDataViews[“End”]));
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.btnOK_CheckPartQty.Click += new System.EventHandler(this.btnOK_CheckPartQty_Click);
//this.chkComplete.Click += new System.EventHandler(this.chkComplete_Click);
Ice.Lib.Framework.EpiNumericEditor nbrScrap = (Ice.Lib.Framework.EpiNumericEditor)csm.GetNativeControlReference(“d1c8f160-f6c5-47dc-8216-d74dddaee3fb”);
nbrScrap.Leave += new System.EventHandler(nbrScrap_Leave);
//grid
Ice.Lib.Framework.EpiUltraGrid ugdJobParts = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference(“05710564-4cf8-4b95-9832-6d475cc6f29e”);
ugdJobParts.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(ugdJobParts_AfterCellUpdate);
this.drpAreaCode.Leave += new System.EventHandler(this.drpAreaCode_Leave);
this.chkComplete.CheckedChanged += new System.EventHandler(this.chkComplete_CheckedChanged);
// End Wizard Added Custom Method Calls
}

They did all of that in a bpm which is the go forward way. You are trying in a customization which it not going to exist in the future.

but for now I am trying to add event on checkbox state changed. And this simple thing is not working. once I get into checkbox event i will call my BPM