Newer Version Available

This content describes an older version of this product. View Latest

Manage Favorites

Favorites let users access frequently used pages in Salesforce. Use User Interface API Favorites resources to manage favorites.

You can create, get, delete, and update favorites, update all favorites at once, and update favorite usage information, for example, the number of times a favorite was clicked. Responses return all fields required to render favorites.

This request returns all the favorites of the context user.
1GET /ui-api/favorites
1{
2  "favorites" : [ {
3    "accessCount" : 1,
4    "iconColor" : "FCB95B",
5    "iconUrl" : "https://.../img/icon/t4v35/standard/opportunity_120.png",
6    "id" : "0MVR00000004GGlOAM",
7    "lastAccessDate" : "2017-08-07T18:51:54.000Z",
8    "name" : "My Best Opportunities",
9    "objectType" : "Opportunity",
10    "sortOrder" : 1,
11    "subtitle" : "Opportunities",
12    "target" : "00BR0000000tTTwMAM",
13    "targetType" : "ListView"
14  }, {
15    "accessCount" : 1,
16    "iconColor" : "A094ED",
17    "iconUrl" : "https://.../img/icon/t4v35/standard/contact_120.png",
18    "id" : "0MVR00000004FOPOA2",
19    "lastAccessDate" : "2017-07-21T21:35:27.000Z",
20    "name" : "John Doe",
21    "objectType" : "Contact",
22    "sortOrder" : 2,
23    "subtitle" : "Contact",
24    "target" : "003R0000001bivAIAQ",
25    "targetType" : "Record"
26  }, {
27    "accessCount" : 1,
28    "iconColor" : "f6707b",
29    "iconUrl" : "https://.../img/icon/t4v35/custom/custom84_120.png",
30    "id" : "0MVR000000004D5OAI",
31    "lastAccessDate" : "2017-08-11T17:24:01.000Z",
32    "name" : "Trend Board",
33    "objectType" : "TabDefinition",
34    "sortOrder" : 3,
35    "subtitle" : "Tab",
36    "target" : "Trend_Board",
37    "targetType" : "Tab"
38  }, {
39    "accessCount" : 1,
40    "iconColor" : "F88962",
41    "iconUrl" : "https://.../img/icon/t4v35/standard/lead_120.png",
42    "id" : "0MVR00000004GOpOAM",
43    "lastAccessDate" : "2017-08-11T17:24:24.000Z",
44    "name" : "Leads to Follow Up on",
45    "objectType" : "Lead",
46    "sortOrder" : 4,
47    "subtitle" : "Leads",
48    "target" : "Lead",
49    "targetType" : "ListView"
50  } ]
51}
Adding a favorite to the top of the list is as easy as knowing what type of favorite it is and how to identify it. For example, to add an Account as a favorite, add it as a Record favorite using its ID. To insert it at the beginning of the list, explicitly set the sortOrder to 1, otherwise it’s inserted at the end of the list.
1POST /ui-api/favorites?target=001R0000002LBXUIA4&targetType=Record&sortOrder=1
2{
3  "accessCount" : 1,
4  "iconColor" : "7F8DE1",
5  "iconUrl" : "https://.../img/icon/t4v35/standard/account_120.png",
6  "id" : "0MVR000000004DFOAY",
7  "lastAccessDate" : "2017-08-11T19:26:04.000Z",
8  "name" : "Global Media",
9  "objectType" : "Account",
10  "sortOrder" : 1,
11  "subtitle" : "Account",
12  "target" : "001R0000002LBXUIA4",
13  "targetType" : "Record"
14}
To track how often a user accesses a particular favorite, make a patch request using the favorite's ID and see the accessCount increment and the lastAccessDate update.
1PATCH /ui-api/favorites/0MVR000000004DFOAY/usage
2{
3  "accessCount" : 2,
4  "iconColor" : "7F8DE1",
5  "iconUrl" : "https://.../img/icon/t4v35/standard/account_120.png",
6  "id" : "0MVR000000004DFOAY",
7  "lastAccessDate" : "2017-08-11T19:31:17.416Z",
8  "name" : "Global Media",
9  "objectType" : "Account",
10  "sortOrder" : 1,
11  "subtitle" : "Account",
12  "target" : "001R0000002LBXUIA4",
13  "targetType" : "Record"
14}
Removing a favorite is as easy and requires using the favorite's ID again.
1DELETE /ui-api/favorites/0MVR000000004DFOAY
To reorder or rename your favorites, you have some options. The first option is to individually update each favorite one by one. When reordering this way, the server automatically updates the sort order of affected favorites in the list so the sort order stays consistent. The second and more useful option is to reorder, rename, and delete favorites in a single request. This option is useful for building an edit dialog where the user can rename some favorites, delete others, and reorder whichever they choose. All these changes can then be made in a single request.
1PUT /ui-api/favorites/batch
Here’s the input for the PUT request:
1{
2  "favorites" : [
3    {
4      "id": "0MVR00000004GOpOAM"
5    },
6    {
7      "id": "0MVR00000004GGlOAM",
8      "name": "Top Opportunities"
9    },
10    {
11      "id": "0MVR000000004D5OAI"
12    }
13  ]
14}
Here’s the response for the PUT request:
1{
2  "favorites" : [ {
3    "accessCount" : 1,
4    "iconColor" : "F88962",
5    "iconUrl" : "https://.../img/icon/t4v35/standard/lead_120.png",
6    "id" : "0MVR00000004GOpOAM",
7    "lastAccessDate" : "2017-08-11T17:24:24.000Z",
8    "name" : "Leads to Follow Up",
9    "objectType" : "Lead",
10    "sortOrder" : 1,
11    "subtitle" : "Leads",
12    "target" : "Lead",
13    "targetType" : "ListView"
14  }, {
15    "accessCount" : 1,
16    "iconColor" : "FCB95B",
17    "iconUrl" : "https://.../img/icon/t4v35/standard/opportunity_120.png",
18    "id" : "0MVR00000004GGlOAM",
19    "lastAccessDate" : "2017-08-07T18:51:54.000Z",
20    "name" : "Top Opportunities",
21    "objectType" : "Opportunity",
22    "sortOrder" : 2,
23    "subtitle" : "Opportunities",
24    "target" : "00BR0000000tTTwMAM",
25    "targetType" : "ListView"
26  }, {
27    "accessCount" : 1,
28    "iconColor" : "f6707b",
29    "iconUrl" : "https://.../img/icon/t4v35/custom/custom84_120.png",
30    "id" : "0MVR000000004D5OAI",
31    "lastAccessDate" : "2017-08-11T17:24:01.000Z",
32    "name" : "Trend Board",
33    "objectType" : "TabDefinition",
34    "sortOrder" : 3,
35    "subtitle" : "Tab",
36    "target" : "Trend_Board",
37    "targetType" : "Tab"
38  } ]
39}
In this single request, we deleted our contact John Doe, moved Leads to Follow Up to the top of the list, and we renamed My Best Opportunities to Top Opportunities.