How can I use a Smart Action to open a dialog box?
You can use a Smart Action to open a dialog box to address various use cases, such as updating custom fields or displaying child objects, and external data. Here we discuss the steps to open a dialog using a custom Smart Action to integration with your workflow.
Configuration Steps in Application Composer
In Application Composer, do the following:
- In the Application Composer Common Setup list, select Smart Actions.
- In the Smart Actions work area, click Create.
- Select UI-based action and click Continue.
- Provide the following information:
- Name: Enter any name. For this example, we'll use My Dialog.
- Object: Select Service Request from the drop-down list.
- Action ID: This field is automatically populated.
- Click Continue.
- On the Availability workspace, do the following:
- Application: Click in the field and select Service Center.
- UI Availability: Click in the field and select the appropriate UI availability.
- Roles: Click in the field and select the roles you want to enable for this dialog.
- Add any conditions you want.
- Click Continue.
- On the Action Details workspace, do the following:
- Navigation Type: Select local.
- On the Confirmation Message leave the field blank, and click Continue, then click Submit which creates the Smart Action.
Configuration Steps in Visual Builder
- Open Visual Builder Studio with Oracle CX Service UI Extension App installed.
- Go to service > ec > sr > edit.
- Choose the Subview Container Layout component from the Structure panel.
- On the property panel, create a case.
No condition is required.
- Create a new section and drill into the new section.
- From the component pallet, search for Dialog and drag
the component into the Structure panel.
- Design the Dialog as needed.
- Copy the Dialog ID as we'll need in the next steps.
- Still in the Edit page, navigate to Event
Listener and create a new listener to
beforeInvokeSmartActionEvent.
Make sure the Input Parameters are properly mapped.
- Drill into the created action chain.
- Add an If action with the following condition: event.detail.smartAction === <your action ID>
- Go to the code view and the dialog open followed by stopPropagation.
- The action should look like the following example:
async run(context, { previous, event }) { const { $page, $flow, $application, $base, $extension } = context; if(event.detail.smartAction === 'CUST-MyDialog-serviceRequests'){ document.getElementById('oj-dialog-485071903-1').open(); return {stopPropagation: true}; } return previous; }