Salesforce User Interface API

With new Salesforce UI API we can get the orgs data and metadata in a single response returned form an Api call. Even Salesforce uses the same UI API to build their Lightning Experience and Salesforce for Android, iOS, and mobile web.

While making calls and getting the data, salesforce does take care of checking the field-level security settings, sharing setting, and perms. We don't have to worry about making the SOQL queries to get record data, getting object metadata and themes info, getting layout info, all this heavy lifting work will be taken care by Salesforce. Best part is that every response is returned in a formatted JSON!

UI API Endpoints are divided into 3 levels namely
1. Records Endpoint
2. Actions Endpoint
3. Favorites Endpoint
For Authentication, User Interface API uses OAuth 2.0 just like all other Salesforce REST APIs does

Reference Links:
1. User Interface API Developer Guide
2. Salesforce Blog by Raja Rao DV

Salesforce UI API helps with below features:

1. Working with Records like Getting child records, Building UI for Picklists, Uploading binary files
2. Working with Actions like Getting Actions for any given record
3. Managing Favorites like user get, create, update, and delete favorites
4. Working with List Views like Getting details about data and metadata for a List View

Lets go ahead and look at some of the key UI API resource urls that we generally use in our real time scenarios and here for our convenience I am going to use Workbench as this tool automatically takes care of making OAuth connection!

Get a Directory of Supported Objects

Helps to find list of all available (Standard and Custom) objects that are supported by User Interface API and accessible to the context user. The directory further includes a ObjectInforUrl: '/services/data/42.0/ui-api/object-info/{objectApiName}' resource for each supported object.

Resource: /ui-api/object-info/

Get Object Metadata

Helps to Get metadata about a specific object. The response includes metadata describing fields, child relationships, record type, and theme.

Resource: /ui-api/object-info/{objectApiName}

Get a Record

Helps to Get a record’s data.

Resource: /ui-api/records/{recordId}

Note:Either Fields or LayoutTypes should be provided with in the url parameter otherwise the API throws an 400 error.

Get Child Records

Helps to Get child records for a specified record and child relationship name. Relationships are connections between records. On a record detail page, each record in a related list has a child relationship to the parent record.

Resource: /ui-api/records/${recordId}/child-relationships/${relationshipName}

Create a Record

Helps to Create a record using POST call and it take a JSON input with Object details and fields data as key-value pair.

Resource: /ui-api/records

Update a Record

Helps to Update a record's data using PATCH call and it take the record id in url parameter along with a JSON input fields data as key-value pair.

Resource: /ui-api/records/{recordId}

Delete a Record

Helps to Delete a record using DELETE call and it take only the record id in url parameter.

Resource: /ui-api/records/{recordId}

Get List View Records

Helps returning record data for a list view.


Get Default Values to Clone a Record

Helps to get the default layout information, object information, and data for cloning a record.

Resource: /ui-api/record-defaults/clone/{recordId}

Benefits of UI API:
1. It provides easy to use/formatted JSON response
2. Field-level security, sharing rules are taken care by Salesforce
3. No SOQL limits (Note: We still have to keep in mind that API limits do still apply!)

Thank you!


Popular posts from this blog

Displaying Toast Message from Modal in Lightning Components

Lightning RecordForm - An enhanced Lightning Data Service

Lightning Component to display dynamic sObject data