Share Utils Methods

The SharinPix package provides the Apex class, ShareUtils, which includes methods that can be applied when sharing albums or images from Salesforce.

Note:

  • Sharing is currently available on the Album component.
  • Ensure that the user performing the Share has been assigned the SharinPix Share Permission.

Share Utils Example

generateUrl

global static String generateUrl(String recordId, String permissionIdOrName)

  • This method can be used to share a complete album with specific abilities.
  • In the below code, “permission” is the name or ID of a SharinPix Permission.
String url = sharinpix.ShareUtils.generateUrl('0018a00001rL2scAAC', 'permission');
System.debug('shareable url: ' + url);

Note: For more information on how to create/edit the custom permission, refer to this article: SharinPix Permission object - How to create and assign custom permission?

generateUrl

global static String generateUrl(String recordId, String permissionIdOrName, List<ShareImageInfos> imageInfos, Map<String, Object> params)

  • This method can be used to share certain images of an album with specific abilities. 
String url = sharinpix.ShareUtils.generateUrl('0018a00001rL2scAAC', 'permission', imageInfos, params);
System.debug('shareable url: ' + url);

Note: imageInfos and params are explained below.

Parameters

imageInfos
  • imageInfos should be in the format below:

List<sharinpix.ShareImageInfos> imageInfos = new List<sharinpix.ShareImageInfos> { new sharinpix.ShareImageInfos('imageId', index)};

List<sharinpix.ShareImageInfos> imageInfos = new List<sharinpix.ShareImageInfos> {
    new sharinpix.ShareImageInfos(
        '3a253a91-705c-4023-ad10-1206e93087d4', 
        0
    ),
    new sharinpix.ShareImageInfos(
        '8e83c16a-bb32-46d2-ae8b-60077bf2af2b', 
        1
    )
};


The index should be set only if the order of the images displayed is to be predefined. In addition to index, the params key orderByIndex should be set to true as explained below.

params
  • The params value should be an Apex Map. The possible keys in it are:
    • orderByIndex (Boolean): set to true to maintain the order of the images according to their “index” values. If set to true, any sort field or direction on the SharinPix Permission is overridden. If set to false, the behaviour will default to the SharinPix Permission’s sort field or the application default.
Map<String, Object> params = new Map<String, Object> {'orderByIndex' => true};


Note:

We advise caution when configuring a SharinPix Permission. If upload, edit or delete permissions are present, the viewers of the shared URL will be able to make changes to your images that will reflect on your Salesforce.

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.