Adaptive Search Queries: Saved Searches

You can create saved searches for your common queries. This lets you reuse a query without defining it each time. You can create saved searches based on the access role, or create default saved searches at the role, user, and site-level.

All Saved Searches are assigned Saved Search numbers that can be used to:
  • Get a saved search
  • Update or delete a saved search
  • Export a saved search and import a saved search

You can migrate saved searches between your environments using REST services. REST uses the saved search number to migrate a saved search from one environment to another without losing the reference to the saved search. Keeping the reference the same across environments allows other areas of your sales application such as the Sales Dashboard to be migrated without any reference changes.

Some Saved Searches may not be supported by the objects during synchronization. This may be because the data in the saved search is not available in the database or that the data does not follow the business criteria.

Below is a list of saved searches that are not supported during sync:

  • My Calls to Log
  • My Overdue Tasks

In addition, the following operators are not supported by the synchronization engine:

  • AllOfTheWords

  • AnyOfTheWords

  • NoneOfTheWords

  • FuzzyMatch

Below are sample request payloads to create, update, and delete saved searches for some scenarios:

Scenario Sample Request Payload

Create role-based saved search

{
    "name": "Search Accounts",
    "entity": "Account",
    "access": "Role",
    "roles": [
        "ORA_ZBS_SALES_REPRESENTATIVE_JOB",
        "ORA_ZBS_SALES_MANAGER_JOB"
    ]
}

Create default saved search for a role

cURL Command

http://servername.fa.us2.oraclecloud.com/crmRestApi/searchResources/11.13.18.05/custom-actions/queries/entityPreferenceForRole

Request Payload

{
    "application": "16d2f11c-29e1-4cf7-8867-7e36080b96d2",
    "roleName": "ORA_ZBS_SALES_ADMINISTRATOR_JOB",
    "entityPreferences": [
        {
            "entity": "Account",
            "queryUuid": "f66e2629-7494-4a4d-b16b-d41fd9391c5a"
        },
        {
            "entity": "Activity",
            "queryUuid": "de850fed-ae4c-40ca-ac7d-f37efe069222"
        }
    ]
}

Create default saved search at the site-level

cURL Command

http://servername.fa.us2.oraclecloud.com/crmRestApi/searchResources/11.13.18.05/custom-actions/queries/entityPreferenceForSite

Request Payload

{
    "application": "16d2f11c-29e1-4cf7-8867-7e36080b96d2",
    "entityPreferences": [
        {
            "entity": "Account",
            "queryUuid": "f66e2629-7494-4a4d-b16b-d41fd9391c5a"
        },
        {
            "entity": "Activity",
            "queryUuid": "de850fed-ae4c-40ca-ac7d-f37efe069222"
        }
    ]
}

Create default saved search at the user-level

cURL Command

http://servername.fa.us2.oraclecloud.com/crmRestApi/searchResources/11.13.18.05/custom-actions/queries/entityPreferenceForUser

Request Payload

{
    "application": "16d2f11c-29e1-4cf7-8867-7e36080b96d2",
    "entityPreferences": [
        {
            "entity": "Account",
            "queryUuid": "f66e2629-7494-4a4d-b16b-d41fd9391c5a"
        },
        {
            "entity": "Activity",
            "queryUuid": "de850fed-ae4c-40ca-ac7d-f37efe069222"
        }
    ]
}    
Create a saved search along with PUID list in correct application ID

cURL Command

{{url}}/crmRestApi/searchResources/latest/custom-actions/exportsavedsearches

Request Payload

{
  "savedSearchNumberList": [
    "59783e65-0513-4169-9faedb9d7d1b105c",
    "SavedSearchNumber2",
    "SavedSearchNumber3",
    "xyz"
  ],
  "entity": "Account",
  "accessValue": "Public",
  "application": "16d2f11c-29e1-4cf7-8867-7e36080b96d2"
}
Update a Saved Search

cURL Command

{{url}}/crmRestApi/searchResources/latest/custom-actions/queries?savedSearchNumber=SavedSearchNumber3

Request Payload

{
  "name": "demo json parser",
  "entity": "Account",
  "keywords": "texas",
  "sort": [
    {
      "attribute": "_score",
      "direction": "descending"
    }
  ],
  "q": null,
  "keywordsFields": [
    "PartyUniqueName",
    "PrimaryAddress",
    "PrimaryContact",
    "PrimaryIndustry",
    "Owner"
  ],
  "aggregations": null,
  "fields": [
    "PartyId",
    "PartyUniqueName",
    "PrimaryAddress",
    "PrimaryContact",
    "PrimaryIndustry",
    "Owner",
    "DoNotContactFlag"
  ],
  "excludeFields": null,
  "applicationData": {
    "461e5791-9f15-4cd1-b5cd-19e8480cbce4": {
      "isListView": true,
      "listLayoutFields": [
        "PartyUniqueName",
        "PrimaryAddress",
        "PrimaryContact",
        "PrimaryIndustry",
        "Owner"
      ],
      "filterFields": [],
      "listLayoutFieldWidths": [
        {
          "attribute": "PartyUniqueName",
          "width": 335
        },
        {
          "attribute": "PrimaryAddress",
          "width": 381
        },
        {
          "attribute": "PrimaryContact",
          "width": 218
        },
        {
          "attribute": "PrimaryIndustry",
          "width": 202
        },
        {
          "attribute": "Owner",
          "width": 159
        }
      ]
    }
  },
  "highlights": {
    "pre": [
      "<b>"
    ],
    "post": [
      "</b>"
    ],
    "fields": [
      "PartyUniqueName",
      "PrimaryAddress",
      "PrimaryContact",
      "PrimaryIndustry",
      "Owner"
    ]
  }
}
Delete a Saved Search

cURL Command

http://servername.fa.us2.oraclecloud.com/crmRestApi/searchResources/11.13.18.05/custom-actions/queries/59783e65-0513-4169-9fae-db9d7d1b105c?metaModelUuid=81f4c054-90c6-45a0-a096-beec3ad68d42&entity=Account&savedSearchNumber=889937479

Import and Export saved searches

You can export saved searches from one environment and import them into another, allowing you to efficiently migrate saved searches between TEST and PROD environments without the use of CSM. This process is facilitated through REST services, utilizing the Saved Search Number (PUID) as a reference. The Saved Search Number remains consistent across environments and can also be used directly in Sales Dashboard queries, ensuring that you do not need to update your queries when moving saved searches from TEST to PROD environments.

Scenario Sample Request Payload
Export a Saved Search API

Request URI:

{{url}}/crmRestApi/searchResources/latest/custom-actions/exportSavedSearches

Request Type: POST

Request Body:
{
  "savedSearchNumberList": [
    "59783e65-0513-4169-9fae-db9d7d1b105c",
    "SavedSearchNumber3",
    "SavedSearchNumber2",
    "SavedSearchNumberRoles",
    "SavedSearchNumber1",
    "SavedSearchNumber4",
    "xyz"
  ],
  "entity": "Account",
  "accessValue": "Public",
  "application": "461e5791-9f15-4cd1-b5cd-19e8480cbce4"
}

Header:

Preference: transient

Import a Saved Search API

Request URI:

{{url}}/crmRestApi/searchResources/latest/custom-actions/importSavedSearches

Request Body:
{
  "items": [
    {
      "entity": "Account",
      "name": "saved search test 3",
      "description": null,
      "queryUuid": "f5ff72a9-36e0-47a5-9b5d-b708edde23e1",
      "savedSearchNumber": "SavedSearchNumber3",
      "access": "Public",
      "keywords": "texas",
      "sort": [
        {
          "attribute": "_score",
          "direction": "descending"
        }
      ],
      "q": null,
      "keywordsFields": [
        "PartyUniqueName",
        "PrimaryAddress",
        "PrimaryContact",
        "PrimaryIndustry",
        "Owner"
      ],
      "aggregations": null,
      "fields": [
        "PartyId",
        "PartyUniqueName",
        "PrimaryAddress",
        "PrimaryContact",
        "PrimaryIndustry",
        "Owner",
        "DoNotContactFlag"
      ],
      "excludeFields": null,
      "applicationData": {
        "461e5791-9f15-4cd1-b5cd-19e8480cbce4": {
          "isListView": true,
          "listLayoutFields": [
            "PartyUniqueName",
            "PrimaryAddress",
            "PrimaryContact",
            "PrimaryIndustry",
            "Owner"
          ],
          "filterFields": [],
          "listLayoutFieldWidths": [
            {
              "attribute": "PartyUniqueName",
              "width": 335
            },
            {
              "attribute": "PrimaryAddress",
              "width": 381
            },
            {
              "attribute": "PrimaryContact",
              "width": 218
            },
            {
              "attribute": "PrimaryIndustry",
              "width": 202
            },
            {
              "attribute": "Owner",
              "width": 159
            }
          ]
        }
      },
      "highlights": {
        "pre": [
          "<b>"
        ],
        "post": [
          "</b>"
        ],
        "fields": [
          "PartyUniqueName",
          "PrimaryAddress",
          "PrimaryContact",
          "PrimaryIndustry",
          "Owner"
        ]
      }
    }
  ],
  "errorSavedSearches": [
    "Out of box saved searches are not extractable 59783e65-0513-4169-9fae-db9d7d1b105c",
    "Saved Search with provided saved search number is not foundxyz"
  ]
}