Use Saved Searches as Filters for Dynamic Choice Lists

Enable salespeople to use saved searches to filter dynamic choice lists. The application supports the new generation of saved searches powered by Adaptive Search. You can create the saved searches in any work area that uses Adaptive Search, including Workspace and Digital Sales work areas.

Before you start

  1. Ensure that the filter criteria field that you'll use for the dynamic choice lists already exists, or has been created.
  2. Create the dynamic choice list and enable filter criteria.

For more information about dynamic choice lists, see the Overview of Dynamic Choice Lists topic.

Enable the Filter Criteria Field

After checking the prerequisites exist, or have been created, you need to enable the field that you want to use as filter criteria in Adaptive Search. Here's how:
  1. In the Setup and Maintenance work area, go to the Configure Adaptive Search task:
    • Offering: Sales
    • Functional Area: Sales Foundation
  2. Click the Setup tab and in the main page, click the Advanced tab.
  3. Find the object that contains your filter criteria field. Check that the Enable checkbox is checked for that field. This allows the field to be searched and filtered within Workspace. If it is enabled, proceed to the next section of this document.
  4. Find the field that you want to use as a filter criteria and check whether the Enable checkbox is enabled. If it's enabled, continue to the "Create Filtered Workspace Search" section. If it isn't enabled, click the Enable checkbox, click the Actions button, and select Partial Publish.
  5. Wait for the publish action to complete and then continue to the Create Filtered Workspace Search section

Create Filtered Workspace Search

Next you need to create a search that is used to limit the values in your dynamic choice list pick list to a specific list of values.
  1. Open the Navigator and click Workspace to open the Workspace page.
  2. Select the object and saved search that you want to use as a filter in the dynamic choice list.
  3. Click Show Filters to display the predefined filters for the saved search you selected and click Edit Filters (the pencil icon).
  4. In the Search field, search for the field that you enabled in Adaptive Search and limit values as needed. Click OK.
  5. Click Save As (the floppy disk icon) and name the search how you want it to appear to users in the CX Sales Mobile picker filter.
  6. In the Shared field, choose to make this search available to Everyone or Specific Roles. Click Create.

Add the Filter and the Dynamic Choice List fields to the Mobile Pages

Now you need to add the filter criteria field to its CX Sales Mobile picker page.
  1. Create a publishable sandbox that includes Application Composer.
  2. Open Application Composer by selecting Application Composer under the Configuration category in the Navigator menu.
  3. Under the Common Setup Menu, or on the Overview page, click Mobile Application Setup.
  4. Click the CX Sales Mobile Composer tab.
  5. In the Application Features pane, click the object that contains the filter criteria field. For example, if you're filtering the dynamic choice list by Account Type, select the Account object.
  6. In the object Views pane, click the Picker layout. Select an active Picker layout, or create one.
  7. Click a field that isn't being used and select the filter criteria field. Click Save.
  8. Navigate to the object where the dynamic choice list field exists. In the object Views pane, click the Summary page layout. Select an active layout, or create one.
  9. Click a field where you would like the filter criteria field to appear and select the field. Click Save.
  10. In the object Views pane, click the Edit page layout. Select an active layout, or create one.
  11. Click a field where you would like the filter criteria field to appear and select the field. Click Save.

Create Mobile Scripts to Validate Selected Values

Finally, to ensure that users are only selecting values from the filtered record set, two mobile scripts need to be created in Application Composer.

One script runs when the user changes the dynamic choice list field value, ensuring it meets the filter criteria of the saved search. This is important in case the user hasn't taken the one-time action to change the filter on the dynamic choice list to the Workspace Search mentioned above. The second runs when the user attempts to save the record, and also ensures that the dynamic choice list meets the required filter criteria of the saved search.
  1. Create a publishable sandbox that includes Application Composer.
  2. Open Application Composer by selecting Application Composer under the Configuration category in the Navigator menu.
  3. Under the Common Setup Menu, or on the Overview page, click Mobile Application Setup.
  4. Click the CX Sales Mobile Scripts tab.
  5. In the CX Object pane, navigate to the object under which you created your filtered dynamic choice list field.
  6. In the object's Script pane, click the + icon to create a new script, and enter a script name and description. Click Create.
  7. Create the first script with these details:
    • In the object's Events pane, select On Field Value Change.
    • In the Select Dependent Field pane, choose your filtered dynamic choice list field.
  8. For the second script, select Before Save in the object's Events pane.
  9. Here is an example script where the dynamic choice list filter exists in the Account object. The same syntax is used for both the On Field Value Change and the Before Save scripts::
    var oracleCxmOutcome = new Result('');
    const optyRow = getCurrentRow();
    const accountsQuery = query('accounts'); //query accounts or another object, depending on the use case
    accountsQuery.setParameters('PartyId', optyRow.getColumn('account_dcl_Id_c')); //be sure to use the ID field for your DCL here, not the name field
    try {
    const accountsResponse = accountsQuery.execute();
    if (accountsResponse && accountsResponse.length > 0) {
    if(accountsResponse[0].getColumn('OrganizationDEO_LSAccountType_c') !== 'SERVICE_CENTER'){ //This checks to see if the filter criteria applied to the DCL are met
      oracleCxmOutcome.setMessage('MESSAGE_TYPE_ERROR', '' ,  'You must choose an organization that is a Service Center. Choose the Service Centers list in the Show filter.');
    oracleCxmOutcome.setOutcomeQualifier("OUTCOME_TYPE_FAILURE"); //The error message here indicates that Service Centers is the name of the saved Workspace Search, and is the filter the user should select
    }
    }
    } catch (e) {
    //failed to get accounts response
    }
  10. Validate the script and click Save.