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 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.
- Choose Objects, then Standard Objects, then Opportunity, and then Fields from the left navigation menu.
- On the Fields page, select the Custom tab and click the Create a custom field icon.
- In the Select Field Type dialog, select the Text option and click OK.
- On the Create Text Field page, do the following:
- 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.
- 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.”.
- 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.
- Choose Standard Objects, then Opportunity, and then Pages from the left navigation menu.
- 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. - In the Duplicate Layout dialog, complete the following fields:
- In the New Layout Name field, specify the name as OCMEmbeddedUIIntegration.
- In the Source Layout field, select Standard layout from the drop-down menu.
- Click Save and Edit.
- 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.
- Select the Mashup Content option. Click Next.
- On the next page, select the OCMEmbeddedFolderUIMashup option that was created earlier and click Insert.
- On the next page, complete the following fields:
- In the Display Label field, enter Documents.
- For Display Icon, click Change Icon so that a document looking icon will be displayed in the opportunities UI as a tab.
- 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. - Click the Next button.
- 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:
- Choose Standard Objects, then Opportunity, and then Server Scripts from the left navigation pane.
- On the Server Scripts Opportunity page, select the Triggers tab.
- Under the Object Triggers section, click Add a new Trigger.
- On the Create Object Trigger page, complete the following fields:
- From the Trigger drop-down menu, select Before Insert in Database.
- In the Trigger Name field, specify the trigger name as OCMCreateFolderTrigger.
- In the Description field, enter the text “Create the OCM folder associated with the opportunity being created.”.
- 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)
- Click Save and Close.
OCMDeleteFolderTrigger
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.- From the Trigger drop-down menu, select Before Delete in Database.
- In the Trigger Name field, specify the trigger name as OCMDeleteFolderTrigger.
- In the Description field, enter “Remove the OCM folder associated with the opportunity being deleted.”.
- 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?") }
- Click Save and Close.