BPM Data Form OK Button Bypass

Hello all! My company has a BPM Data Form that was created to gather info for a sign…

The typical OK button that would close the form and pass the “1111” code in the BPM is hidden, and I created the Submit button to replace it. When clicked, this button checks all of the date fields to make sure the same date hasn’t been selected. The user is prompted if any dates match. If there are no duplicated dates, then the form should pass the “1111” code to the BPM and close, but instead acts like the user clicked the close (X) button and gives the message that the user canceled the operation. How can I pass an OK code to the BPM so it can continue its process?

I have tried assigning “1111” to the button value…

EpiDataView edvt = ((EpiDataView)(this.oTrans.EpiDataViews["CallContextBpmData"]));
edvt.dataView[edvt.Row]["ButtonValue"] = "1111";

But when the form closes it still says the operation was canceled by the user. Thanks in advance for any help you can give!

Why not just just use the OK button, and have your customization make it disabled, until the conditions are met

Thanks @ckrusen, I didn’t think of that route. I did, however, with the aid of another, find a solution that I believe works. I’ll post the code in the next reply. Thanks again!

Another thing you could have done was to just add an event handler to the original OK button.

Thanks to @Rick_Bird, who guided me in the right direction. Since you can’t create a method for the single button you are required to have in a BPM Data Form, I ended up hiding that button and placing a new one on the form to handle all of the checks required before continuing on in the BPM. But it seems that the BPM Data Form looks for the click of that one required button, and anything else is viewed as a cancel. In the new method for the new button I have all of the checks and balances, and if everything is okay to proceed it then processes the code below to close out the form and continue with the BPM.

EpiButton btn0 = (EpiButton)csm.GetNativeControlReference("????????????????????");
btn0.Visible = true;
btn0.PerformClick();

I tried that, but that original button (btn0) didn’t show up in the wizard for me to add the Click method.

To add event handlers to Native controls, you have to add a few lines of code yourself.

  1. Declare a variable of the control type, in the Script section
  2. Get the reference to the native control
  3. Add the handler

  1. Dispose of the event handler
  2. Create the actual handler function

You would have had one issue to overcome, that I don’t know how to do off the top of my head. That would be to stop the form from closing, when those date conditions aren’t met.

3 Likes

Question - If I were to do this on Clock Out on the MES main menu, would this event handler not allow the “Native” built in process to execute?

From I’ve been told, adding an event handler does just that. It adds to handler, and doesn’t replace it.

The following code uses the += to add an event handler to the existing object:

this.btnOK.Click += new System.EventHandler(this.btnOK_Click);

Had it used "=" , then it would have probably replaced any existing event handlers. That might also cause an issue when the native disposal "-="is called and there isn’t a matching eventhandler in the object.

And while it’s just a guess, I believe the event handlers fire in order they were added to the object. So any native event handler would fire first, and then the one you added.

3 Likes

Update I added your code to the MES Clock out button and Put a MessageBox.Show. It did exactly what you said, fired after the Existing Handler. Thanks great stuff!

2 Likes