How can I dynamically set a group of users as potential owners of an activity?
 Technote (FAQ)
 
Question
Sometimes it is necessary to determine a group of users as potential owner of an activity dynamically, for each process instance separately, at runtime.
 
Answer
This can be achieved by setting the group name 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 group name somehow
    String groupString = getInput().getValue();
    // Set custom attribute value
    service.setCustomAttribute(piid, "group", groupString);
  } catch  (Throwable anyException) {
    anyException.printStackTrace();
  }
  // user code end
}


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

Note: for LDAP you have to specify the fully qualified DN of the group for this verb.

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>Group Members</staff:id>
       <staff:parameter id="GroupName">%group%</staff:parameter>
       <staff:parameter id="AlternativeGroupName1"/>
       <staff:parameter id="AlternativeGroupName2"/>
       <staff:parameter id="IncludeSubgroups">false</staff:parameter>
       <staff:parameter id="Domain"/>
     </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 #: 1155635
IBM Group: Software Group
Modified date: Nov 13, 2004