Monday, May 13, 2013

Launch Workflow from OAF Page

Using class oracle.apps.fnd.framework.webui.OANavigation provided by Oracle for Workflow API, you can launch workflow directly from OAF Page.  There are two ways to launch workflow :

1.  Oracle PL/SQL API (wf_engine)
2.  Java Wrappers

In this blog, we shall launch a workflow from OAF page.

1.  Create a submit button and name the partial event as "launchWF"
2.  Write below java procedure to invoke workflow

import oracle.apps.fnd.framework.webui.OANavigation;

    public void launchWF(OAPageContext pageContext)
    {
        String PItemType = "XXSALES";
        String PProcess = "SALES_WF";
        String PItemKey = "SALES-001";  // This can be a random item key generated
   
        OANavigation wf = new OANavigation();
   
        // Now create Workflow Process
        wf.createProcess(pageContext, PItemType, PProcess, PItemKey);
   
        // Set Sales Order Number
        wf.setItemAttrText(pageContext, PItemType, PItemKey,"ORDER_NO", "101");
   
        // Start Workflow Process
        wf.startProcess(pageContext, PItemType, PProcess, PItemKey);

    }


3.  Call the above procedure in ProcessFormRequest Method

    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    {
    super.processFormRequest(pageContext, webBean);

    if ("launchWF".equals(pageContext.getParameter(EVENT_PARAM)))
      {
        launchWF(pageContext);
      }
    }


4 comments:

  1. Hi Mohammad ,
    this is good , but as we know we are storin data into table in our OAF page , how i can connect that this process is related to this page and this DB table .

    can you please provide us with video example .
    Regards

    Baraa Yahya

    ReplyDelete
    Replies
    1. You need to have 2 fields reference in the table, the itemtype(the internal name) and itemkey (unique number probably the primary key of your table). After workflow process is created, you can update view object or table with item type and item key.

      Delete
  2. Dear Abdul,

    Please advice How to create OAPageContext pageContext, OAWebBean webBean in case of webservice implementations.
    How we can do the same thing in SOA Suite for exposing the serive as webservice.

    Regards,
    Anu

    ReplyDelete
  3. Good Job Abdul. Thank You So much..

    ReplyDelete