Skip to main content
Assign Record Type
Leonard Zhong avatar
Written by Leonard Zhong
Updated over a week ago

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

Variable

API Name

Record

Data Type

Record

Object

Opportunity

The object this Flow related to

Available for Input

True

Available for Output

True

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

Get_Donation_RT

Autogenerated

Record Type - Developer Name

Donation

Record Type Name from earlier step

SObject Record Type

Opportunity

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

Assess_Donation_RT_Result

Autogenerated

Outcome Label

Exists

Outcome API Name

Exists_Donation_RT_Result

Autogenerated

  • Appended _Donation_RT_Result to prevent API name clash error

Resource

{!Get_Donation_RT.RecordTypeId}

  • Get_Donation_RT is the object the logic is to apply to (in this case the record retrieved from the Apex component)

  • RecordTypeId is the field the logic is to apply to

Operator

Is Null

The logic the decision is to use

Value

False

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

Set_Record_Type_ID

Autogenerated

Variable

{!Record.RecordTypeId}

  • Record is the object the logic is to apply to (in this case the Opportunity record)

  • RecordTypeId is the field the logic is to apply to

Operator

Equals

The logic the assignment is to use

Value

{!Get_Donation_RT.RecordTypeId}

  • Get_Donation_RT is the object the logic is to apply to (in this case the record retrieved from the apex component)

  • RecordTypeId is the field the logic is to apply to

Your flow should look like this:

Did this answer your question?