Rename a SharinPix album using a Flow (Admin-Oriented)
This article demonstrates how to rename a SharinPix album using a Salesforce Flow.
For this demo, we will use the Lead and Opportunity objects.
The setup will be in such a way that when a Lead record is converted into an Opportunity, the Lead's album is copied to the Opportunity record.
Creation of the Flow
This section demonstrates how to create a Flow that invokes the Apex class, RenameAlbum in order to rename albums on Lead records and copy them to the converted Opportunity record.
To do so, follow the steps below:
Go to Setup. In the Quick Find Box, type Flows.
Under Process Automation, select Flows.
Click on the New Flow button.
Select the option Record-Triggered Flow, and click on the Create button.

After clicking on Create, the Configure Start modal will be displayed. Fill in the modal as indicated below:
Select Object: Lead
Configure Trigger: A record is created or updated
For the Set Entry Conditions section:
Select All Conditions Are Met (AND)
For the Field, select ConvertedOpportunityId
Select Is Changed for the Equals parameter
Select {!$GlobalConstant.True} for the Value parameter
When to Run the Flow for Updated Records: Every time a record is updated and meets the condition requirements
Optimize the Flow for: Actions and Related Records
Click on Done to save the configurations.

Next, add an Action element.


On the _Action _modal, use the search bar to find the sharinpix__RenameAlbum** ** Apex class.
Click on sharinpix__RenameAlbum.

On the Action modal for sharinpix__RenameAlbum, populate the fields as indicated below:
Label: Rename Lead album
Description: Enter a description (optional)
Current Album ID: {!$Record.Id}
Note: This is a mandatory field and refers to the current Lead ID.
New Album ID: {!$Record.ConvertedOpportunityId}
Note: This is a mandatory field and refers to the converted Opportunity ID.

Click Done to save the Action configurations.
Save the Flow and activate it.
Demo
To test the Flow:
Go on a Lead record and upload some images to its corresponding SharinPix album.
Then, convert the Lead.
Go to the converted Opportunity record. The images previously uploaded on the Lead are now available on the converted Opportunity album.
DEPRECATED: Creation of the Process Builder
This section demonstrates how to create a Process Builder that invokes the Apex class RenameAlbum to rename an album.
To do so, follow the steps below:
Go to Setup. In the Quick Find Box, type Process Builder
Under Process Automation, select Process Builder
Click on New
For the newly-created Process Builder:
For the field, Process Name enter SharinPix Rename Lead To Opportunity Album
Enter a description for the process (This step is optional)
For the field The process starts when, select A record changes
Click Save

Once on the Process Builder editor:
Click on Add Object
For the field Object, select Lead
For the field Start the process, choose when a record is created or edited
Click on Save

Next, click on Add Criteria
For the field Criteria Name, enter On Lead to Opportunity conversion
For the field Criteria for Executing Actions, select Conditions are met
Inside the Set Conditions section
Choose Converted Opportunity ID as the field
Then, select Is Changed as the operator, Boolean as the type and True as the value
Leave the field Conditions as All of the conditions are met (AND)

Next, click on Add Action
For the Action Type, choose Apex
For the Action Name, enter Rename Opportunity album
For the Apex Class, select sharinpix__RenameAlbum
Inside the Set Apex Variables:
For the field New Album ID, choose Field Reference as the type. For the value, choose Converted Opportunity ID
For the field Current Album ID, choose Field Reference as the type and Lead ID as the value

Click Save when done
You can now activate the Process Builder.

