This article will show you how to assign a record type to a record in Salesforce. In this example, we will set the field Record Type (RecordTypeId
) on the Opportunity
record to Donation
.
Create a Record Variable
Open Toolbox
and click New Resource
. Create a new resource with the following information:
Item | Value | Comment |
Resource Type |
|
|
API Name |
|
|
Data Type |
|
|
Object |
| The object this Flow related to |
Available for Input |
|
|
Available for Output |
|
|
Identify Record Type Name
Open Setup
β Object Manager
β Opportunity
β Record Types
and open the record type you are looking to set.
Copy the value in the Record Type Name
field.
Get Record Type
In your Flow click the +
icon to add a new Element and select Action
. Then select the Apex component md_npsp_pack__GetRecordTypeComponent
.
Add the following information to your action:
Item | Value | Comment |
Label | Get Donation RT |
|
API Name |
| Autogenerated |
Record Type - Developer Name |
|
|
SObject Record Type |
| API name of the object you are assigning the record type against |
Your flow should look like this:
Check Record Type
It is best practice to check that a result exists before any assigning the value. This allows the "default" Salesforce functionality to run should you fail to get your desired record type in the future (for example, if you deleted or changed the API name of that record type in the future).
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 | Assess Donation RT Result |
|
API Name |
| Autogenerated |
Outcome Label |
|
|
Outcome API Name |
| Autogenerated
|
Resource |
|
|
Operator |
| The logic the decision is to use |
Value |
| The logic the decision is to use |
Your flow should look like this:
Assign Record Type
In your Flow click the +
icon to add a new Element and select Assignment
. Configure your decision with the following information:
Item | Value | Comment |
Label | Set Record Type ID |
|
API Name |
| Autogenerated |
Variable |
|
|
Operator |
| The logic the assignment is to use |
Value |
|
|
Your flow should look like this: