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.
ConnectApi Utilities
| Utility | Description |
|---|---|
| ConnectApi.ConnectUtilities.unwrapApexWrapper() | Unwraps obfuscated, Apex-wrapped objects into known types such as Map<String, Object>. Example from Apex Debug log: core.connect.apex.ApexMapWrapper@7270879d |
Example
This example calls getManagedContentForSite(siteId, contentKeyOrId, showAbsoluteUrl) to get a custom content type with an image reference and uses the ConnectApi.ConnectUtilities.unwrapApexWrapper() utility.
1ConnectApi.ManagedContentDeliveryDocument res =
2 ConnectApi.ManagedContentDelivery.getManagedContentForSite ('0DMXXXXXXXXXXXXXXX','MCLXXXXXXXXXXXXXXXXXXXXXXXXX',true);
3
4//before contentBody field ApexWrapper is unwrapped
5system.debug(res.contentBody);
6
7//unwrap contentBody field in res
8Map<String,Object> contentBody = (Map<String,Object>)ConnectApi.ConnectUtilities.unwrapApexWrapper(res.contentBody);
9
10//after contentBody field ApexWrapper is unwrapped, but image field still wrapped
11system.debug(contentBody);
12
13//before image field ApexWrapper is unwrapped
14system.debug(contentBody.get('Image'));
15
16//unwrap Image field in contentBody
17Map<String,Object> Image = (Map<String,Object>)ConnectApi.ConnectUtilities.unwrapApexWrapper(contentBody.get('Image'));
18
19//after image field ApexWrapper is unwrapped
20system.debug(Image);
21
22//replace wrapped primary_image in contentBody with unwrapped version
23contentBody.put('Image', Image);
24
25//after contentBody field ApexWrapper is unwrapped, with image field also unwrapped
26system.debug(contentBody);