How can I set a user as activity potential owner dynamically?
 Technote (FAQ)
 
Question
Sometimes it is necessary to determine the potential owner of an activity dynamically, for each process instance separately, at runtime.
 
Answer
This can be achieved by setting the user ID in a previous activity and using a custom attribute to store it. This custom attribute can be accessed in the staff resolution verb of the staff activity.
Set the custom attribute in a previous Java snippet activity using the following code sample (bold section):

/*
 * Java Snippet Activity Method
 * NOTE: Only code in the USER CODE SECTION will be saved:
 * // user code begin {Java Snippet Activity}
 * // user code end
 * @generated FlowNode_3
 */
public void javaSnippet_3() throws com.ibm.bpe.api.ProcessException {
  // user code begin {Java Snippet Activity}
  try {
    PIID piid = (PIID)processInstance().getID();
   
    // First retrieve the business process bean
    javax.naming.InitialContext initialContext =
                    new javax.naming.InitialContext();
    Object obj =
      initialContext.lookup("com/ibm/bpe/api/BusinessProcessHome");
    com.ibm.bpe.api.BusinessProcessHome home =  
      (com.ibm.bpe.api.BusinessProcessHome)
         javax.rmi.PortableRemoteObject.narrow(
                  obj,
                  com.ibm.bpe.api.BusinessProcessHome.class);
    com.ibm.bpe.api.BusinessProcess service = home.create();

    // Retrieve user value somehow
    String userString = getInput().getValue();
    // Set custom attribute value
    service.setCustomAttribute(piid, "user", userString);
  } catch  (Throwable anyException) {
    anyException.printStackTrace();
  }
  // user code end
}


This custom attribute can be referenced in the staff resolution verb of a following activity, by using the "Users by user ID" verb, and entering %yourCustomAttributeName% (%user% in this sample) as parameter in the Staff Verb GUI.

For your information, this results in the following FDML snippet:
 ...
 <wf:potentialOwner>
   <wf:staff type="staffSupportService">
     <staff:verb xmlns:staff="http://www.ibm.com/schemas/workflow/wswf/plugins/staff">
       <staff:id>Users by user ID</staff:id>
       <staff:parameter id="UserID">%user%</staff:parameter>
       <staff:parameter id="AlternativeID1"/>
       <staff:parameter id="AlternativeID2"/>
     </staff:verb>
   </wf:staff>
</wf:potentialOwner>
...
 
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > Enterprise Edition (EE)
Operating system(s): z/OS
Software version: 5.1
Software edition:
Reference #: 1155633
IBM Group: Software Group
Modified date: Nov 12, 2004