This article will show you how set a field in Salesforce conditional on existing data inside Salesforce. In this example, we will set the custom field field Lead Source (LeadSource
) on the Contact
record but only if a value does not already exist for that field.
Create Flow
To create your Flow, go to Setup → Process Automation → Flows
and click New Flow
. Select Autolaunched Flow (No Trigger)
from the available options and click Create
.
Create Record Variable
Open Toolbox
and click New Resource
. Create a new resource with the following information:
Item | Value | Comment |
Resource Type |
|
|
API Name |
| Autogenerated |
Data Type |
|
|
Object |
| The object this Flow relates to |
Available for Input |
|
|
Available for Output |
|
|
Add Decision
In your Flow click the +
icon to add a new Element and select Decision
. Configure your decision with the following information:
Item | Value | Comment |
Label | Check Lead Source |
|
API Name |
| Autogenerated |
Outcome Label | Exists |
|
Outcome API Name |
| Autogenerated |
Resource |
|
|
Operator |
| The logic the decision is to use |
Value |
| The logic the decision is to use |
Your Flow should now look like:
Assign Value
Since you only want to perform your assignment if the field Lead Source does not already exist, you can add your assignment under the Default Outcome
branch.
In your Flow click the +
icon to add a new Element and select Assignment
. Configure your assignment with the following information:
Item | Value | Comment |
Label | Set Lead Source |
|
API Name |
| Autogenerated |
Variable | {!Record.LeadSource} |
|
Operator |
|
|
Value |
|
|
Your Flow should now look like:
Save Flow
You can now save your Flow. Naming conventions are not of importance but for the framework we use please see equivalent section in the article Assign a Default Value. In this scenario we would set:
Item | Value |
Flow Label |
|
Flow API Name |
|
Create Field Set
Whenever you are decisioning against Salesforce data, you must add the relevant field into the field set.
To create your field set, go to Setup → Object Manager → [Object] → Field Sets
and click New
. The naming convention is not used by the integration, but we recommend applying a format which mimics the MoveData Field Sets:
Item | Value |
Field Set Label |
|
Field Set Name |
|
Where is this used? |
|
Add Field to Field Set
You can now add your field to your field set:
Register Flow in MoveData Pipeline
You will now need to register your Flow in the MoveData Pipeline. For instructions on how to do this please see Assign a Default Value - Register Flow in MoveData Pipeline. In this scenario we would clone PIPELINE_DONATION_CONTACT_MAPPING
and set the following values:
Item | Value | Comment |
Handler |
| API Name of your Flow |
Type |
|
|
Label |
|
|
MoveData Pipeline Setting Name |
|
|
Order |
|
|
Register Field Set in MoveData Pipeline
To register your field set, go to Setup → Custom Code → Custom Metadata Types
and click Manage Records
next to MoveData Pipeline Setting
.
We recommend finding the existing entry which points to the Managed Field Set your newly developed Field Set will be running alongside of. In this case it is DONATION_CONTACT_FIELDSET_001
. Open the entry and click Clone
.
Configure your metadata entry with the following information and click Save
:
Item | Value | Comment |
Handler |
| API Name of your Field Set |
Type |
|
|
Label |
|
|
MoveData Pipeline Setting Name |
|
|
Order |
|
|
Your Field Set is now registered in MoveData.
Reprocess Notification
You can now open a relevant notification and click Reprocess
. Observe that the value Raisely
is set in the execution log and resultant record:
If you change the field to some other value and reprocess the notification you will notice it does not update to Raisely due to the decision to perform the assignment only if a value does not already exist for the field Lead Source.