UIApi

UIApi is the API used to power the Lightning Experience, allowing you to call all the UI APIs from SalesForce using just a few lines of code. For example, to call an endpoint, configuring this component calls your endpoint and returns the JSON. This action does not count against your Salesforce API call limit because the call comes from the client side instead of the server side.

UIApi allows you to pull all the fields for a specific layout - automatically rendering the correct type, its helpText, and whether it's a required field or not. When you provide an sObject, it returns a parsed JSON object.

  • getFieldsFromLayout – the only method currently available.
  • uniqueID - You should provide a unique ID because UIApi could be used multiple times on the same page.

To configure UIApi:

  1. Instantiate the UIApi component.

    Example

    <framework:UIApi uniqueID="eventFields" aura:id="fieldUIApi"/>
    JS
  2. Then provide the object (EventApi_Event_c below) and the API (fieldUIApi below):

    Example

    getCustomFields : function (component) {
       if (!component.get('v.customFieldsFound')) {
          component.find('fieldUIApi').getFieldsFromLayout('EventApi_Event_c');
          }
       }
    JS

ActionUtils

You can use ActionUtils to abstract out server calls to asynchronous servers. 

The component sends your current class, the component object, the string action and the parameters of the call. A Javascript Promise is returned in response.  That Promise includes a then() array. The Promise is then executed. If the Promise is rejected, you receive a Toast message.

  • executeAction - Syncs the context of your action. [Enter] the following attributes:
    • The first attribute is your helper file.
    • component is your component object.
    • The third attribute is the action you wish to execute on the server side.
    • The fourth parameter is an array of parameters for the action in the third attribute.

The Promise is returned using the return parameters that you include. 

To instantiate this component, use the following code example.

return ActionUtils.executeAction(this, component, 'c.getSalesOrder', {
           salesOrderId: this.getSalesOrderIdFromCookie(),
           eventId: component.get('v.params.record.id'),
           doDuplicateCheck: false
       })
       .then(function(result) {
           component.set('v.so', result);
           return result
       });
XML

 

UrlUtil

If you’re in the portal, and you’re going to be switching between communities that have prefixes and other communities that do not have prefixes, UrlUtil allows Lightning to detect whether a prefix exists or not.

To configure this component,  enter a URL into your instantiation code. If that URL doesn’t have a site prefix, Lightning will add it. For example, in "/force.com/partners/<page name>", “partners” is the site prefix. If you call a URL that doesn’t have “partners”, the component will automatically add it. This allows for less server contact.

To instantiate this component, use the following code example:

UrlUtil.addSitePrefix('/EventApi__attendee_ticket?id='+event.currentTarget.dataset.id)
XML