OK/ Cancel – Yes/ No Dialog Box in a BPM

Andrew ClementsEpicor Developement

Recently I was asked to create a method directive on the jobEntry.Update method that needed to ask the user whether they wanted to send an email to a party.

This is pretty straightforward in a customization, using the MessageBox.Show built, however, due to BPM’s running on the server,  System.Windows.Forms cannot be referenced and MessageBox cannot be used in BPM custom code.

This post details the solution I came up with, using the ‘Call BPM Data Form’ caller from within the ‘BPM Workflow Designer’

I have kept it as simple as possible so, the workflow fires on checking of the ‘Unfirm’ checkbox’ and displays either the message  ‘Cancel’ or the message ‘OK’ depending on which button is pressed.

  1. Select ‘Method Directive Maintenance’ from the menu.
  2. Select ‘Method Code’ of ‘JobEntry’.
  3. Select the ‘Update’ directive.
  4. Click on the ‘PreProcessing’ tab and then ‘Select ‘New Pre Processing’ from the menu bar.
  5. Give the new directive a name. I called mine ‘Test Dialog’.
  6. Click on the ‘Design’ button to invoke the workflow designer.
  7. Create a condition to check whether the ‘Unfirm’ checkbox has been changed

  1. Drag in the ‘Call BPM Data Form’ from the callers section and join it to the ‘True’ branch of the ‘Enable Firm’ condition.

  1. We now need to build the dialog box by clicking on the ‘BPM data form’ item
  2. Click on the ‘named’ link in the ‘actions’ section.
  3. Click on the ‘Run Designer’ button.
  4. Once the designer has been invoked you will see any data form you have already created. In this case we want to create a new one, so select ‘New Form’ from the menu bar
  5. Call the form YesNoBase and give it a title of ‘Simple Dialog’ example.

  1. We now need to design the dialog box
  2. Click on the fields tab and select ‘New Button’ from the menu bar. The button will default with the OK button. Enter ‘Cancel’ in the label for 1112. The values ‘1111’ and ‘1112 are important as these are the ones you will use to interpret the user response

  1. Your form is now ready, so you can test it from the ‘Actions -> Test BPM Data Form’ menu

  1. Save the form and close down the ‘BPM Data Form Designer’.
  2. Select the ‘YesNoBase’ form in the ‘Actions’ part of the ‘Call BPM Data Form’ caller.
  3. We are now going to add a condition to the BPM that will return a message of ‘OK’ if the user presses the ‘OK’ button and ‘Cancel’ if the user presses the ‘Cancel’ button.
  4. Add the condition to the BPM and join the data form caller to the condition
  5. Call the Condition ‘Test OK/ Cancel’
  6. Add the condition ‘The specified call context field is equal to the specified expression.
  7. Change the ‘specified call context field’ to ‘Button Value’

  1. Change the ‘specified expression’ to 1111 which the value returned when the user selects OK.
  2. Add a message to the true branch that displays ‘OK’ and a message to the ‘False’ branch’ that displays cancel.
  3. Finally, add an exception to the ‘Cancel’ branch, so that the ‘Firming of the job doesn’t occur.

  1. Press the ‘Save and Exit’ button
  2. Check the ‘Enabled’ box in the method directive form.
  3. Save the directive
  4. To test this you need to have an unfirm job opne in the ‘Job Entry screen.
  5. Click on the ‘Unfirm’ checkbox and the dialog box will appear

  1. Press ‘Cancel’ and the message that you entered for the ‘Cancel’ branch appears and most importantly the exception is called and the job is not formed.
  2. Press ‘OK’ and the message attached the ‘OK’ branch appears and the job is firmed

It is worth noting that BPM data fors can be customised, so you can tailor the dialog box to your specific needs.

Hope that helps – as ever please let me have your feedback.