Oracle CRM On Demand Desktop Customization Guide > Adding Custom Fields to Oracle CRM On Demand Desktop > Process of Adding Book Support to a New Top-Level Object >

Adding Book Selector Controls to Form UI


The following topics describe how to add book selector controls to forms:

To view a list of top-level objects that support books refer to Record Types That Support Books.

This task is a step in Process of Adding Book Support to a New Top-Level Object.

Adding UI Controls for Books

This procedure shows you how to add the UI controls to display a record's book on a form UI scriptable autocomplete control, which shows the books tree dialog that is used. This procedure shows how the control is set up on an Opportunity form.

The tree view of a book is displayed on the UI with a scriptable autocomplete control and a button control. These controls display a dialog box, showing the book's tree. The scriptable autocomplete control is an expanded version of an autocomplete control. Both autocomplete and scriptable autocomplete controls are used to display associated records, but scriptable autocomplete control can be implemented with additional logic for the value that the control displays. For more information on control elements used in the forms_XX.xml file, see Changing the XML Code in the forms_12.xml File.

To add a UI control for a book

  1. Edit the forms_12.xml file, available in the Oracle CRM On Demand Desktop customization package.
  2. Locate the record's Team control in forms_12.xml, add the Book UI control on the form UI underneath this control, and update head_opportunity_book_info for your new type label.

    In the following XML code:

    • The first cell, <cell size="13">...</cell>, contains two controls:
      • <static id="head_opportunity_book_info">, which is a label acting as a header.
      • <edge id="book_separator"/>, which is a horizontal ruler that underlines the header.
    • The second cell, <cell size="22">...</cell>, contains a static control label under the <!-- right side captions --> text and a scriptable autocomplete control under <!-- right side fields -->.

      Each control has a unique identifier (ID), which is used to refer to the control within the script. For example, for the button control <button id="btn_book_select">, the ID is btn_book_select. The value for all names that are prefixed with the number sign (#) as in the name #btn_book_select are specified in the package_res.xml file.

      The Book UI control XML code is as follows:

    <cell size="13">
    <stack layout="horz">
    <cell size="110">
    <static id="head_opportunity_book_info">
    <text>#head_opportunity_book_info</text>
    </static>
    </cell>
    <cell>
    <stack layout="vert">
    <cell size="7"></cell>
    <cell size="1">
    <edge id="book_separator"/></cell>
    </stack>
    </cell>
    </stack>
    </cell>
    <cell size="22">
    <stack layout="horz" spacing="5" padding="5">
    <!-- right side captions -->
    <cell size="122">
    <stack spacing="5" layout="vert">
    <cell size="22">
    <static id="lbl_book_of_business">
    <text>#lbl_book_of_business</text>
    </static>
    </cell>
    </stack>
    </cell>
    <!-- right side fields -->
    <cell>
    <stack spacing="5" layout="vert">
    <cell size="22">
    <stack layout="horz">
    <cell>
    <scriptable_edit id="book_of_business" tab_order="39">
    <field value="string"></field>
    </scriptable_edit>
    </cell>
    <cell size="5"></cell>
    <cell size="22">
    <button id="btn_book_select" tab_order="40">
    <text>#btn_book_select</text>
    </button>
    </cell>
    </stack>
    </cell>
    </stack>
    </cell>
    </stack>
    </cell>

    NOTE:  You must set the scriptable edit control Id and the book selector button control Id to btn_book_select. Otherwise, the UI controls will not function.

  3. Save the forms_12.xml file.

Registering the UI Controls in the Form Handler

After the UI controls have been added to the forms_12.xml file, register the controls in the form handler by completing the following procedure.

To register the UI controls in the form handler

  1. Edit the forms.js file, and locate the form handler function.

    For example, for an Opportunity record, the function is od_opportunity_form().

  2. Add the following function call inside the form handler function:

    register_book_control(ctx, team_control_id);

    In this function call, team_control_id is the Id of Team autocomplete_list control on a form. For example,:

  3. Locate the Id of the autocomplete_list control that displays the record's team, for example:

    <autocomplete_list id="TeamToOpportunity" tab_order="36">

  4. For the above autocomplete_list control example Id, define the function register_book_control() as follows:

    register_book_control(ctx, "TeamToOpportunity");

    The team_control_id argument is not required if no team is associated with the object. For example, for an Opportunity object, the function looks like the following:

    register_book_control(ctx, "TeamToOpportunity");

    NOTE:  Add the register_book_control() function call anywhere after the ctx.form_links_manager.init_new(); line. Otherwise, book prefilling will not work properly when a new record is created. For more information on book prefilling, see To prefill the default book on new records.

  5. Save the forms.js file.

The form is populated with a control for the selected book name, and the button that brings up a dialog box displaying a book tree. Using this dialog box, a user can select different book.

Oracle CRM On Demand Desktop Customization Guide, Version 5.2 Revision A Copyright © 2018, Oracle and/or its affiliates. All rights reserved. Legal Notices.