Records Class

Access information about record motifs, which are small icons used to distinguish record types in the Salesforce UI.

Namespace

ConnectApi

Records Methods

The following are methods for Records. All methods are static.

getMotif(communityId, idOrPrefix)

Returns a Motif object that contains the URLs for a set of small, medium, and large motif icons for the specified record. It can also contain a base color for the record.

API Version

28.0

Requires Chatter

No

Signature

public static ConnectApi.Motif getMotif(String communityId, String idOrPrefix)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
idOrPrefix
Type: String
An ID or key prefix.

Return Value

Type: ConnectApi.​Motif

Usage

Each Salesforce record type has its own set of motif icons. See ConnectApi.​Motif.

getMotifBatch(communityId, idOrPrefixList)

Gets a motif for the specified list of objects. Returns a list of BatchResult objects containing ConnectApi.Motif objects. Returns errors embedded in the results for those users that couldn’t be loaded.

API Version

31.0

Requires Chatter

No

Signature

public static ConnectApi.BatchResult[] getMotifBatch(String communityId, List<String> idOrPrefixList)

Parameters

communityId
Type: String
Use either the ID for a community, internal, or null.
idOrPrefixList
Type: List<String>
A list of object IDs or prefixes.

Return Value

Type: BatchResult[]

The BatchResult.getResults() method returns a ConnectApi.Motif object.

Example

String communityId = null;
List<String> prefixIds = new List<String> { '001', '01Z', '069' };

// Get info about the motifs of all records in the list.
ConnectApi.BatchResult[] batchResults = ConnectApi.Records.getMotifBatch(communityId, prefixIds);
    
for (ConnectApi.BatchResult batchResult : batchResults) {
    if (batchResult.isSuccess()) {
        // Operation was successful. 
        // Print the color of each motif.
        ConnectApi.Motif motif;
        if(batchResult.getResult() instanceof ConnectApi.Motif) {
            motif = (ConnectApi.Motif) batchResult.getResult();
        }
        System.debug('SUCCESS');
        System.debug(motif.color);
    }
    else {
        // Operation failed. Print errors.
        System.debug('FAILURE');
        System.debug(batchResult.getErrorMessage());
    }
}