Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Records Class
Namespace
Records Methods
getMotif(communityId, idOrPrefix)
API Version
28.0
Requires Chatter
No
Signature
public static ConnectApi.Motif getMotif(String communityId, String idOrPrefix)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, 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.
getMotifBatch(communityId, idOrPrefixList)
API Version
31.0
Requires Chatter
No
Signature
public static ConnectApi.BatchResult[] getMotifBatch(String communityId, List<String> idOrPrefixList)
Parameters
- communityId
- Type: String
- ID for an Experience Cloud site, internal, or null.
- idOrPrefixList
- Type: List<String>
- A list of object IDs or prefixes.
Return Value
Type: ConnectApi.BatchResult[]
The ConnectApi.BatchResult.getResult() method returns a ConnectApi.Motif object and errors for motifs that didn’t load.
Example
1String communityId = null;
2List<String> prefixIds = new List<String> { '001', '01Z', '069' };
3
4// Get info about the motifs of all records in the list.
5ConnectApi.BatchResult[] batchResults = ConnectApi.Records.getMotifBatch(communityId, prefixIds);
6
7for (ConnectApi.BatchResult batchResult : batchResults) {
8 if (batchResult.isSuccess()) {
9 // Operation was successful.
10 // Print the color of each motif.
11 ConnectApi.Motif motif;
12 if(batchResult.getResult() instanceof ConnectApi.Motif) {
13 motif = (ConnectApi.Motif) batchResult.getResult();
14 }
15 System.debug('SUCCESS');
16 System.debug(motif.color);
17 }
18 else {
19 // Operation failed. Print errors.
20 System.debug('FAILURE');
21 System.debug(batchResult.getErrorMessage());
22 }
23}