Tuesday, June 22, 2010

How to create Workflow based navigation for Oracle self service Pages?

Steps:

Workflow Builder Related Changes
1.
Create a work flow with a process like below.
You can see three functions. Each denotes a page.

Note: Each function should have an attribute with internal name OAPAGE and value similar to "page=/oracle/apps/ak/employee/webui/EmployeePG".
Invoking OANavigation.getNextPage will return this page.

Example:


OAF Related Changes


2. When user opens the Update link,(as shown in above image) we start the workflow and navigate the user to the next page using the following code.
---------------------------------------------------------
    String nextPage = null;
    String wfkey = null;
    String address_Id = pageContext.getParameter("addressId");
    String address_Name = pageContext.getParameter("addressName");
    HashMap params = new HashMap();
    params.put("addressId",address_Id);
    params.put("addressName",address_Name);

    if ("update".equals(pageContext.getParameter(EVENT_PARAM))) // check if update event is fired
      {
        if(!OANavigation.isWorkflowInProgress(pageContext))
// starting a new workflow only if there is no wf associated with existing pageContext.
        {
          wfkey = am.invokeMethod("getNewWFId").toString();
          OANavigation.createProcess(pageContext,"MANADDUP","UPDATE",wfkey); 
//creating new workflow process
          OANavigation.startProcess(pageContext,"MANADDUP","UPDATE",wfkey);
        }
        nextPage = OANavigation.getNextPage(pageContext,"MANADDUP",wfkey,"UPDATE",false);
// this will give the value of next page which we have added in function attributes

        pageContext.setForwardURL(pageContext.getApplicationJSP()+"?"+nextPage,
            null,        
            OAWebBeanConstants.KEEP_MENU_CONTEXT,
            null,           
            params,           
            true,          // Retain AM        
            OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
            // Do not display breadcrumbs                          
            OAException.ERROR);
    }


---------------------------------------------------------

The above code goes in the CO of the page which holds the Update button.

3.  In the CO of subsequent pages we can get the next page by providing the result of the current function.

---------------------------------------------------------
if ("next".equals(pageContext.getParameter(EVENT_PARAM)))
      {  

        nextPage = OANavigation.getNextPage(pageContext,"NEXT");
// we are passing result as NEXT.

        pageContext.setForwardURL(pageContext.getApplicationJSP()+"?"+nextPage,
            null,          
            OAWebBeanConstants.KEEP_MENU_CONTEXT,  
            null,             
            null,             
            true,          // Retain AM          
            OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
            // Do not display breadcrumbs                            
            OAException.ERROR);
    }

---------------------------------------------------------
Similarly if you pass result as PREVIOUS then you will get value of nextPage as the previous page.

4. In the CO of last page use the same code to move the WF ahead but do not use the value of nextpage as it will be null.
---------------------------------------------------------
        nextPage = OANavigation.getNextPage(pageContext,"SUBMIT"); // this will end the WF. Value of nextPage will be null.
---------------------------------------------------------

Thanks,
Agry

No comments:

Post a Comment