> For the complete documentation index, see [llms.txt](https://docs.sharinpix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sharinpix.com/documentation/cookbook/share-utils-methods.md).

# 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.

{% hint style="warning" %}
**Note:**

* Sharing is currently available on the Album component.
* Ensure that the user performing the Share has been assigned the [SharinPix Share Permission](/documentation/access-and-security/sharinpix-permission-sets.md).
  {% endhint %}

### Share Utils Example <a href="#share-utils-example" id="share-utils-example"></a>

#### generateUrl <a href="#generateurl" id="generateurl"></a>

*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.

```apex
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?*](/documentation/access-and-security/sharinpix-permission-object-how-to-create-and-assign-custom-permission.md)

#### generateUrl <a href="#generateurl_1" id="generateurl_1"></a>

*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.&#x20;

```java
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**)};

```java
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.

```javascript
Map<String, Object> params = new Map<String, Object> {'orderByIndex' => true};
```

{% hint style="danger" %}
**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.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sharinpix.com/documentation/cookbook/share-utils-methods.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
