Hello guys, In this article, we will learn how can we use Flow builder, Process builder, and Custom metadata types to update records.
I have a scenario in which I have one custom metadata type named as STATESCITIESPINCODE which contains pin codes of corresponding cities with their states, now whenever a user creates the records he enters state name and city name so our process builder calls flow which having logic how to get pin code corresponding to state and city to enter by the user while creating the record and then our process builder update the record with the pin code.
so first let's create the custom metadata type which having the states, cities, and corresponding pin codes,
So go to Setup >> Enter custom metadata in the search box >> click on Custom Metadata Types under Develop
so I have custom metadata types with three custom fields City, State, and Pincode

now we'll create the flow
so go to setup >> Enter Flow >> Click on Flows under Process Automation
So in our flow, first of all, we'll create the variables for this click on Manage on the left and then click on New Resource then the popup will come in the search box enter variable and click on the variable
Repeat the steps for creating the three variables varCity, varState, varPincode, and varId of datatype Text.
Create another variable varUpdateCityRecord with datatype as Record and Object type is as City, which will be used to update the record
Create another variable varGetPincodeRecord with datatype as Record and Object type is as StatesCitiesPincode( which is our custom metadata object), this will be used to store the value of pin code.
Now we have created the variables now we'll search for the records in the custom metadata type. so for this click on the element on the left and drag the GetRecords under data, a popup will come, give a suitable label, in the object search your custom metadata type name, in the condition requirement select Conditions are met
Now Click on Assignment under the Logic and drag it to right again the popup will come, give some Label then set the variable values
next and final step is to update the Record variable, for this click on the Update Records and drag it to the right again popup will come, give the suitable name and then in the select variable select the varUpdateCityRecord variable which will update the Record with the pin code.
join all them together and the finally your flow will look like this
Save the flow as autolauchedflow, and don't forget to activate it.
Now create the process builder which will run when we try to save our city Object record and will call the flow to update the record with the corresponding pin code
Select City as an object, in the criteria, select No criteria—just execute the actions!
and in the immediate actions Select Flow as an action, give an action name and select your flow which you just created and provide values to the flow variables
Save your process builder and don't forget to activate it
Now everything is done try to create the City Record give postcode and state values and click on save and your record will be updated with the corresponding pin code.
That's it guys,
I have a scenario in which I have one custom metadata type named as STATESCITIESPINCODE which contains pin codes of corresponding cities with their states, now whenever a user creates the records he enters state name and city name so our process builder calls flow which having logic how to get pin code corresponding to state and city to enter by the user while creating the record and then our process builder update the record with the pin code.
so first let's create the custom metadata type which having the states, cities, and corresponding pin codes,
so I have custom metadata types with three custom fields City, State, and Pincode

now we'll create the flow
so go to setup >> Enter Flow >> Click on Flows under Process Automation
So in our flow, first of all, we'll create the variables for this click on Manage on the left and then click on New Resource then the popup will come in the search box enter variable and click on the variable
Repeat the steps for creating the three variables varCity, varState, varPincode, and varId of datatype Text.
Create another variable varUpdateCityRecord with datatype as Record and Object type is as City, which will be used to update the record
Create another variable varGetPincodeRecord with datatype as Record and Object type is as StatesCitiesPincode( which is our custom metadata object), this will be used to store the value of pin code.
Now we have created the variables now we'll search for the records in the custom metadata type. so for this click on the element on the left and drag the GetRecords under data, a popup will come, give a suitable label, in the object search your custom metadata type name, in the condition requirement select Conditions are met
Now Click on Assignment under the Logic and drag it to right again the popup will come, give some Label then set the variable values
next and final step is to update the Record variable, for this click on the Update Records and drag it to the right again popup will come, give the suitable name and then in the select variable select the varUpdateCityRecord variable which will update the Record with the pin code.
join all them together and the finally your flow will look like this
Save the flow as autolauchedflow, and don't forget to activate it.
Now create the process builder which will run when we try to save our city Object record and will call the flow to update the record with the corresponding pin code
Select City as an object, in the criteria, select No criteria—just execute the actions!
and in the immediate actions Select Flow as an action, give an action name and select your flow which you just created and provide values to the flow variables
Save your process builder and don't forget to activate it
Now everything is done try to create the City Record give postcode and state values and click on save and your record will be updated with the corresponding pin code.
That's it guys,