Form Personalization: Open Sales Order form with parameters

We can open a standard form with parameters. In this case, We are going to open Sales order by passing header id parameter

 Steps:

  • Open the Form FMB file from Form Builder
  • Check the parameters that are in the form
  • Use parameter to pass as input in the form function
  • Create a personalization to trigger event
  • Create action to set default where clause
  • Create action to execute the query

Open Sales Order form and do personalize

  • Go to Help --> Diagnostics --> Custom Code --> Personalize

Create a personalization à Condition à Trigger Event

  • Trigger the event when input header id parameter passed

Create an action set default where condition

  • Set the default where clause by using input header id parameter

Create another action to execute the query

  • Execute the Query to see the relates sales order in the form for the input header id parameter that is passed



Read More »
Blogger Tricks
*/

Script to generate Page URL for Form Function

We can generate the page URL for Oracle form functions or OAF form functions just by passing the Function name.

Oracle Standard API will return the page URL directly.

Main Input parameters

  • Form Function Name/Id
  • Responsibility Id
  • Responsibility Application Id
  • Security Group Id
  • Form Function Parameters
Steps

  1. Get the Responsibility id, Responsibility Application id and Security Group Id
  2. Get the Function id for given Function Name
  3. Pass the above information to Oracle standard API: FND_RUN_FUNCTION.get_run_function_url 


 CREATE OR REPLACE FUNCTION XX_FORM_FUNCTION_URL

    RETURN VARCHAR2

AS

    l_url            VARCHAR2 (2000);

    L_RESP_ID        NUMBER := FND_PROFILE.VALUE ('RESP_ID');

    L_RESP_APPL_ID   NUMBER := FND_PROFILE.VALUE ('RESP_APPL_ID');

BEGIN

    SELECT FND_RUN_FUNCTION.get_run_function_url (

               fnd_function.get_function_id ('XX_OC_OEXOEORD_VW'),

               L_RESP_APPL_ID,

               L_RESP_ID,

               0,

               'STARTUP_MODE=SALES_ORDERS HEADER_ID=20747414')

      INTO l_url

      FROM DUAL;


    RETURN l_url;

EXCEPTION

    WHEN OTHERS

    THEN

        l_url := SQLERRM;

        RETURN l_url;

END;

Read More »
*/

Script to encode OAF page or Form Function parameters

We need to encode form parameters when opening an Oracle form with parameters from OAF page.

Generally, we use standard oracle FND API to generate URL and it automatically encrypts parameters when you pass them.

You can use below script If you have a scenario to prepare page URL externally and needs to pass parameters.

  • Get the responsibility id, Responsibility Application id and security group id
  • Get the database id
  • Prepare the parameters string
  • Call the URLEncrypt API to encrypt the parameters

CREATE OR REPLACE FUNCTION XX_ENCODE_PARAMETERS (p_header_id IN NUMBER)

    RETURN VARCHAR2

AS

    l_db_id               VARCHAR2 (255);

    l_mac_data            VARCHAR2 (2000);

    l_resp_id             NUMBER := FND_PROFILE.VALUE ('RESP_ID');

    l_resp_appl_id        NUMBER := FND_PROFILE.VALUE ('RESP_APPL_ID');

    l_security_group_id   NUMBER := 0;

    l_param_text          VARCHAR2 (2000);

BEGIN

    l_param_text := 'STARTUP_MODE=SALES_ORDERS HEADER_ID=' || p_header_id;

    l_db_id :=

        fnd_profile.value_specific ('APPS_DATABASE_ID',

                                    NULL,

                                    l_resp_id,

                                    l_resp_appl_id,

                                    l_security_group_id);


    IF (l_db_id IS NULL)

    THEN

        l_db_id := fnd_web_config.database_id;

    END IF;


    l_mac_data := fnd_web_sec.URLEncrypt (l_db_id, l_param_text);

    RETURN l_mac_data;

EXCEPTION

    WHEN OTHERS

    THEN

        l_mac_data := SQLERRM;

        RETURN l_mac_data;

END;

Read More »
*/

Get Selected row count in View object in OAF

Scenario: Get the selected rows count to display to user after performing some action

  • Take the view object.
  • Get all the rows of view object
  • Take a loop to process the rows of view object
  • Get the row information
  • Check if the row is selected or not by verifying the row's attribute

 int selectedRowCount = 0;

try{

CustomerSearchVOImpl selectedSerachVO = getCustomerSearchVO1();

Row row[] = selectedSerachVO.getAllRowsInRange();

for(int i=0; i<row.length; i++){

CustomerSearchVORowImpl searchRow = (CustomerSearchVORowImpl)row[i];

if (searchRow.getSelection()!=null && searchRow.getSelection().equals("Y")){

selectedRowCount = selectedRowCount + 1;

}

}

}

Read More »
*/

show dialog message as error in OAF

Scenario: Display the error message to user when something is done after clicking or something gone wrong with user action

  • Take the exception object
  • Pass the text information that need to show as error message
  • Use the putDialogMessage method to display error message

 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

{

super.processFormRequest(pageContext, webBean);

if("cancelReview".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))){

Object confirmation;

confirmation = new OAException("Customer information not reviewed as cancelled",OAException.ERROR);

pageContext.putDialogMessage((OAException)confirmation);

}     

}

Read More »
*/

Show dialog message as success in OAF

Scenario: Display the confirmation message to user when something is done after clicking

Take the exception object

Pass the text information that need to show as confirmation message

Use the putDialogMessage method to display confirmation message

 public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)

{

super.processFormRequest(pageContext, webBean);

if("confirmReview".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))){

Object confirmation;

confirmation = new OAException("Customer information reveiwed successfully",OAException.CONFIRMATION);

pageContext.putDialogMessage((OAException)confirmation);

}     

}

Read More »
*/

Set MessageStyledText value dynamically in OAF

Scenario: Set the text on a item dynamically based on certain criteria

  • Get the text value that need to be set
  • Open the styled text bean
  • Assign the text value to styled text bean

 public void processRequest(OAPageContext pageContext, OAWebBean webBean)

{

super.processRequest(pageContext, webBean);

String customerName = pageContext.getParameter("CustName");

OAMessageStyledTextBean customerNameBean = (OAMessageStyledTextBean)webBean.findChildRecursive("StaticCustomerName");

customerNameBean.setValue(pageContext,customerName);

}

Read More »
*/