Posted by: openmaximo | 28/08/2009

Making Workflow Memo field required when canceling or rejecting


Another of the features usually requested by clients is to make the Workflow Memo field required when you cancel or reject a workflow assignment. This post describes the steps to implement this feature.

The first step is to override the psdi.workflow.WFInstance MBO. Create the 4 classes required for a customized MBO.

After generating the 4 classes edit your WFInstance class and override the completeWorkflowAssignment(int,int,String) method.

The method code should be something like this. In this example I’m making the memo field required when the action is either WO CANCEL or WO REJECT.

  /**
   * Overriden method to implement empty memo validation when canceling or
   * rejecting a WO.
   *
   */
  public void completeWorkflowAssignment(int assignment, int action, String memo)
      throws RemoteException, MXException {
    String wfID = this.getMboValueData(“WFID”).getData();

    String processName = this.getThisProcessName(wfID);
    String actPerformed = this.getActionName(action, processName);
    if (actPerformed.equalsIgnoreCase(“WO CANCEL”)
        || actPerformed.equalsIgnoreCase(“WO REJECT”)) {
      if (memo.trim().length() == 0) {
        throw new MXApplicationException(“workflow”, “MemoEmpty”);
      }
    }
    super.completeWorkflowAssignment(assignment, action, memo);
  }

The only problem you’ll have is that the getThisProcessName(String) and getActionName(int,String) are private which means you cannot access them, you’ll have to copy them to your class. If only they were protected… The MemoEmpty message is a customized message thay you have to add to MAXMESSAGES.

Finally update the class for your WFACTION MBO in database configuration, rebuild and redeploy your EAR.

Best regards,

António Jacob Costa

Advertisements

Responses

  1. Can you please explain what “Create the 4 classes required for a customized MBO”

    I am looking at creating a custom class from at task in a PO workflow. Can you please tell how I would get the PO number.

    Thanks

    • Hi Steve,

      MBO classes come in groups of 4 being 2 interfaces and 2 classes. The 2 interfaces are remote interfaces for RMI invocation and the 2 classes are for the Mbo and the MboSet. If you create a new persistent Mbo you should create these 2 interfaces and 2 classes with the following structure.

      • interface MyMboSetRemote extends psdi.mbo.MboSetRemote
      • interface MyMboRemote extends psdi.mbo.MboRemote
      • class MyMboSet extends psdi.mbo.MboSet implements MyMboSetRemote
      • class MyMbo extends psdi.mbo.Mbo implements MyMboRemote

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: