# Duplicate SharinPix Images Using a Flow (Admin-Oriented)

## Overview

The <mark style="color:$danger;">`DuplicateImagesAutomation`</mark> Invocable Apex method allows users to duplicate **specific images** from one SharinPix album to another, with the option to include associated **tags**. This is ideal for use cases where only a subset of images (e.g., those flagged or selected in a custom UI) needs to be copied across records.

This invocable method is designed for use in **Salesforce Flows** and supports image transfer between any two records with linked SharinPix albums (e.g., from Case to another Case, Site to Project, etc.).

This article covers the following:

* [Input Parameters for DuplicateImagesAutomation](#input-parameters)
* [Flow Setup](#flow-setup)
  * [Step 1: Select Images from Source Album](#step-1-select-images-from-source-album)
  * [Step 2: Fetch Related Work Order Line Items](#step-2-fetch-related-work-order-line-items)
  * [Step 3: Choose Destination WOLIs](#step-3-choose-destination-wolis)
  * [Step 4: Execute Duplication](#step-4-execute-duplication)
  * [Step 5: Test and Deploy](#step-5-test-and-deploy)
* [Demo: Work Order to Work Order Line Item Example](#demo-work-order-to-woli-flow-example)

{% hint style="warning" %}
**Prerequisites**

Before configuring this automation, ensure the following:

* You have the latest **SharinPix Managed Package** installed.
  {% endhint %}

## Input Parameters

Below are the inputs required when using the `DuplicateImagesAutomation` invocable method in a Salesforce Flow. These must be populated for the image duplication to succeed.

| Parameter          | Description                                                                                                                                        |
| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| imageIds           | A list of SharinPix **Image Public IDs** that should be duplicated. Example: <mark style="color:$danger;">`["id1", "id2"]`</mark>. *(Required)*    |
| destinationAlbumId | The **ID of the destination record** , where the duplicated images should be stored. This record must be linked to a SharinPix album. *(Required)* |
| tags               | Boolean indicating whether to duplicate **tags** along with the images. *(Optional)*                                                               |

## Flow Setup

This example is based on a **Work Order to Work Order Line Item** scenario, where specific images from a Work Order’s SharinPix album are duplicated into the album of a related Work Order Line Item.

### Step 1: Select Images from Source Album

Use a **Screen Element** with the <mark style="color:$danger;">`SharinPix Album (LWC)`</mark> component.

* **Label** : <mark style="color:$danger;">`Select Images to copy`</mark>
* Users select images from the Work Order's SharinPix album
* In the <mark style="color:$danger;">`AlbumId`</mark> field, create a new resource of type **Variable** and Data Type **Text.** For the**API Name,** please type in "**recordId**"

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-ea2d1776397281228087a6f355a6c5183e4b466f%2FClick%20on%20the%20\(18\)%20\(1\)%20\(1\).png?alt=media)

### Step 2: Fetch Related Work Order Line Items

Add a **Get Records** element to retrieve WOLIs related to the current Work Order.

* **Object** : Work Order Line Item
* **Filter** : <mark style="color:$danger;">`WorkOrderId`</mark> equals <mark style="color:$danger;">`Source_Album.RecordId`</mark> (or Work Order ID contextually)
* Store **All Records** , with **All Fields**

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-e5d4323a39982919c332c6ab8fd1830134f7fa13%2FClick%20on%20the%20\(12\)%20\(1\)%20\(1\).png?alt=media)

### Step 3: Choose Destination WOLIs

Add another **Screen Element** using the **Data Table** component.

* **Label** : <mark style="color:$danger;">`Choose Work Order Line Item on which to paste duplicated images`</mark>
* Source Collection: The WOLIs from Step 2
* Allow selection of one or multiple WOLIs (as needed)
* Configure the rows and columns of the data table as per your use case. In this case, we will show <mark style="color:$danger;">`Work Order Line Item Number`</mark> as the column.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-e5514e403cb0889d967718f51930e8f4691532b5%2FClick%20on%20the%20\(21\)%20\(1\)%20\(1\).png?alt=media)

### Step 4: Execute Duplication

Add an **Apex Action** calling <mark style="color:$danger;">`sharinpix__DuplicateImagesAutomation`</mark>.

* **Label** : <mark style="color:$danger;">`Duplicate Selected Images`</mark>
* **List of Image Ids** : Value from Screen 1 (selected image IDs - <mark style="color:$danger;">`{!Source_Album.selectedImageIds}`</mark> )
* **Destination Album ID** : Selected WOLI(s) from the Data Table
* **Duplicate Tags** : <mark style="color:$danger;">`True`</mark> (optional)

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-ad01ae97c24a4a07a6226878f89b05ff8625099a%2FClick%20on%20the%20\(22\)%20\(1\)%20\(1\).png?alt=media)

### Step 5: Test and Deploy

* Save and activate the Screen Flow.
* Add it to a **Lightning Page** and on the configuration page of the flow, tick the "**Pass record ID into this variable** " checkbox.
* Validate that selected images are duplicated to the chosen WOLIs, with tags preserved if configured.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-ee37e2ce36afb43d7af00c1ebf9f65b7224f7d2f%2FClick%20on%20the%20\(23\)%20\(1\)%20\(2\).png?alt=media)

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-420343edf81d57b013b66436b6813742eb6a4285%2FTemplate%20\(5\)%20\(1\)%20\(1\).png?alt=media)

## Demo: Work Order to WOLI Flow Example

On the Word Order record <mark style="color:$danger;">**`00000001`**</mark>, we have two related Work Order Line Item. Images are selected, and the 'next' button is pressed.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-c5a6d73ffdc5e81cdab0a618cf66d8373891d607%2FClick%20on%20the%20\(24\)%20\(1\)%20\(1\).png?alt=media)

The next screen shows the data table displaying all the related WOLIs by their WOLI Number. Choose the WOLI record(s) on which the previously selected images will be duplicated and click next. The images have been successfully duplicated.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-9a075e9d3915a4801a38bb3fccab1194a02a100e%2FClick%20on%20the%20\(25\)%20\(1\)%20\(1\).png?alt=media)

The images and tags appear on the previously selected WOLI record's album.

![](https://2221230591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5EvYRrLbUyvRh8o1jmMG%2Fuploads%2Fgit-blob-42bd662c1ab292208af6a345e39fee05c09c3b37%2FClick%20on%20the%20\(26\)%20\(1\)%20\(1\).png?alt=media)
