Configure Specific Business Object Integration

In this last section, you will perform the steps required to add the OCM embedded folder UI within a specific Oracle Sales and Service application business object.

In this section, we will once again be using opportunities, but any business objects can be updated using these steps such as service requests, campaigns, events, etc. This entails creating a custom field within the opportunity to store the unique OCM folder ID. These steps will also add the Documents tab into the opportunity details page that exposes the OCM embedded folder UI through a Mashup using the OCM folder ID specific to the opportunity.

Create a Custom Field

A custom field is specific to the business object it is created in. These variables are unique to each instance of the business objects that are created.

To create a custom field to contain the unique OCM folder ID related to the specific opportunity item:
  1. To re-enter the application composer, click Tools in the upper left corner of the page and then select Application Composer from the drop-down list.
  2. Choose Objects, then Standard Objects, then Opportunity, and then Fields from the left navigation menu.
  3. On the Fields page, select the Custom tab and click the Create a custom field icon.
  4. In the Select Field Type dialog, select the Text option and click OK.
  5. On the Create Text Field page, do the following:

    1. In the Display Label field, specify the name as OCMFolderId. The Name field is automatically filled in based on the value specified in the Display Label field.
    2. In the Description field, enter the text “Custom variable for the specific Opportunity object to store the unique Folder Id being used the OCM Opportunities Collaboration integration.”.
    3. Click Save and Close.

Extend the Business Object

Business Objects can be extended using a Mashup (like the one we created above) to expose an external application such as OCM within the Business Object UI.

To create a new opportunity page layout to include the OCM integration:
  1. Choose Standard Objects, then Opportunity, and then Pages from the left navigation menu.
  2. On the Opportunity: Pages page, in the Details Page Layouts section, click Duplicate Details Page Layout.

    Note:

    If a custom page has already been created, then that page can be used for the OCM Integration instead of creating a new one and step 3 can be skipped.
  3. In the Duplicate Layout dialog, complete the following fields:

    1. In the New Layout Name field, specify the name as OCMEmbeddedUIIntegration.
    2. In the Source Layout field, select Standard layout from the drop-down menu.
    3. Click Save and Edit.
  4. In the Details Layout page, select the Add icon from the bottom of the left navigation menu in the Subtabs Region section to add the OCM embedded UI.
  5. Select the Mashup Content option. Click Next.
  6. On the next page, select the OCMEmbeddedFolderUIMashup option that was created earlier and click Insert.
  7. On the next page, complete the following fields:

    1. In the Display Label field, enter Documents.
    2. For Display Icon, click Change Icon so that a document looking icon will be displayed in the opportunities UI as a tab.
    3. In the Edit Script field, paste the following script:
      println("Opportunity Documents Tab Selected: " + Name)
      // Get the current user security context
      def secCtx = adf.context.getSecurityContext()
      // Get the current OCM user id based off the current Oracle Sales and Service User
      def OCMUserId = adf.util.OCMSearchUserFunction(secCtx.getUserName())
      // Now check to see if the OCM user has been shared to this folder
      boolean isFolderShared = adf.util.OCMIsFolderSharedFunction(OCMFolderId_c, OCMUserId)
      if (!isFolderShared) {
        // Share the current user as a Manager to the OCM Folder associated to this item
        adf.util.OCMShareFolderFunction(OCMFolderId_c, OCMUserId, "manager")
      }
      println("Loading OCM Embedded Docs UI")
      return OCMFolderId_c +'?options={"documentsView":{"layout":"grid","header":{"create":{"folder":true},"upload":true,"trash":true},"actions":{"open":{"file":true},"uploadNewVersion":true,"download":true,"delete":true,"shareLink":true,"members":true}},"documentViewer":{"actions":{"download":true,"uploadNewVersion":true,"shareLink":true},"sidebar":{"conversation":true}}}'
      

      Note:

      This script automatically assigns the manager role to each user accessing the folder. This could potentially be further refined to grant the opportunity owner the manager role while giving other users the contributor role.
    4. Click the Next button.
    5. Click Save and Close.

Add Event Triggers

An event trigger checks for an event and when that event occurs, it runs the code associated with the trigger.

OCMCreateFolderTrigger

To add a server script object trigger to create the related OCM folder when the opportunity is created:

  1. Choose Standard Objects, then Opportunity, and then Server Scripts from the left navigation pane.
  2. On the Server Scripts Opportunity page, select the Triggers tab.
  3. Under the Object Triggers section, click Add a new Trigger.
  4. On the Create Object Trigger page, complete the following fields:

    1. From the Trigger drop-down menu, select Before Insert in Database.
    2. In the Trigger Name field, specify the trigger name as OCMCreateFolderTrigger.
    3. In the Description field, enter the text “Create the OCM folder associated with the opportunity being created.”.
    4. In the Edit Script field, paste the following script, replacing <OCMRootFolderId> with the actual OCM root folder ID that was captured in OCM in the initial steps above (for example, F572711F9E557436A646AEC295F044A3C39B0):
      println("Opportunity.BeforeInsert(OCMCreateFolderTrigger): " + Name)
      def OCMParentFolderId = "<OCMRootFolderId>"
      // Create a new OCM folder under the parent folder based off the item name
      println("Create OCM Opportunity Folder under Pararent Folder Id: " + OCMParentFolderId)
      def OCMFolderId = adf.util.OCMCreateFolderFunction(OCMParentFolderId, Name)
      // and assign that new folder id to the OCMFolderId item variables
      setAttribute("OCMFolderId_c", OCMFolderId)
    5. Click Save and Close.

OCMDeleteFolderTrigger

To add a server script object trigger, in a new Create Object Trigger page, to remove the related OCM folder when the opportunity is deleted:

Note:

The implementer may choose not to implement this step if it is realized that any content placed in the OCM opportunity folder should be retained even after the opportunity has been deleted.


  1. From the Trigger drop-down menu, select Before Delete in Database.
  2. In the Trigger Name field, specify the trigger name as OCMDeleteFolderTrigger.
  3. In the Description field, enter “Remove the OCM folder associated with the opportunity being deleted.”.
  4. In the Edit Script field, paste the following script:
    println("Opportunity.BeforeDelete(OCMDeleteFolderTrigger): " + Name + "(" + OCMFolderId_c + ")")
    // Make sure that we have a folder to delete
    if (OCMFolderId_c != null) {
      adf.util.OCMDeleteFolderFunction(OCMFolderId_c)
    } else {
      println("Warning: No OCMFolderId associated to the Opportunity?")
    }
  5. Click Save and Close.