Slaesforce FAQ

can i use a randomize fundtion in a salesforce flow

by Prof. Kaylin O'Conner Published 2 years ago Updated 2 years ago

Can I Create Read-Only fields in Salesforce flow?

You may also want to download our free Flow reference guide . You're probably familiar with formula fields in Salesforce. With a little bit of Excel-like code you can create a read-only field that automatically computes a value for you based on other fields.

When should you use Salesforce flow?

If you need to perform mass updates across multiple unrelated records, or complex logic into opportunity conversion, these are common examples for when you should use Flow. The use cases for Flow are endless, and its capabilities are growing with every Salesforce release.

What is the use case for Salesforce flow?

The use cases for Flow are endless, and its capabilities are growing with every Salesforce release. Formerly Visual Flow, Salesforce Flow has gone through significant upgrades to give us the Flow Builder interface, after being completely rebuilt from the ground up!

How do I edit a record in a Salesforce flow?

Essentially, any time you want to edit a record in the Salesforce database, you’ll need to use one of these Data elements. These will also dynamically display depending on the type of Flow you’re running. If you’re running a ‘before triggered’ Flow, you’ll only be able to use ‘Get’, for example.

Why use flow in Salesforce?

Flows allow you to build complex business automation using clicks instead of code. As an admin, Flows are going to be your best friend because you will be able to handle the majority of complex business requirements without the help of a Salesforce developer! The benefit of Salesforce Flow is that they are easy to maintain because anyone ...

What is loop in Salesforce?

Loops allow you to handle multiple variables at once using collections. Data elements include Create, Update, Get, or Delete records. Essentially, any time you want to edit a record in the Salesforce database, you’ll need to use one of these Data elements.

What does it mean to call a flow?

To ‘call’ a Flow means that something happens in order to kickstart the Flow process. This could be a Salesforce record change, from another process in Apex/Process Builder, or automated on a recurring schedule. When you create a new Flow, you’re prompted to select the type of Flow you wish to create.

What are the building blocks of a flow?

There are 3 main “building blocks” of any Flow: 1. Elements are the individual building blocks of the Flow. These perform logical actions such as assignments, decisions, or loops. There are also data elements that will query the database or commit record changes. 2. Connectors determine which element leads to which.

The Formula Resource

The Formula resource calculates a numeric value using functions and elements in your flow. Consider the following when creating a Formula resource.

Formulas for Validating Flow User Input

You can use a formula to validate flow user input by selecting Validate when configuring an input field on a Screen element.

1. Always Test Your Flows

I often preface my tutorials with ‘Always build in a Sandbox or Developer Environment’ – and this one is just as important. Make sure you test your solution THOROUGHLY before pushing it into Production.

2. Consider Using Subflows

A Subflow is an Auto-launched Flow that is called from one or more parent Flows. They often have at least one variable that has been made available for Input and another that has been made available for Output.

3. Never Perform DML Statements In Loops

I harp on about this a lot too – Never EVER perform a DML Statement inside of a loop. This means never performing a repetitive Get, Update, Create, or Delete (the pink Data elements) inside of a Loop.

4. Document Your Flows

It is inevitable that your Flow will be viewed by other Salesforce Administrators and potentially Consultants. You should always create supporting documentation to make it easier for them to understand what your Flow does and the key elements and functions that it performs, to make their job of maintaining the org easier.

5. Never Hard Code Ids (Use Constants IF You Must)

The beauty of Flow is that it has the ability to reach out and get specific information. As a result, you should be able to access things like Record Ids or Record Type Ids with ease, without having to hardcode them.

6. Plan For Faults (And Handle Them)

Faults and errors are bound to happen when working with Flows and other automation. As such, it’s important to make sure they’re handled correctly.

7. Utilise Before-Save Flows for Same Record Updates

This is one of the three key takeaways from the Record-Triggered Automation page of the Salesforce Architects Guide. It is better to perform another change to the record before it is pushed into the system, rather than saving it, assigning another change and then saving the record a second time.

Why use flow formulas?

Flow formulas serve many of the same use cases that custom field formulas do. However, the biggest benefit in Flow is that you can usually use a formula to save yourself steps in the Flow design itself (usually by removing Assignment elements). This can make your Flows easier to follow. So, if you find yourself doing some tricky math ...

What is the difference between flow formulas and custom formulas?

In Flow formulas your merge fields are the other resources (like variables) you create and the various Flow global variables. In custom fields, your merge fields reference other fields on the object.

What is a formula in flow?

What's a formula in Flow? Formulas are resources, just like variables. The big difference is that, unlike variables, you don't directly set a value on the formula resource (i.e. they're "read only"). Whenever you access the value of the resource, it's calculated based on a formula you provide.

Randomizer Flow

The flow that I decided to create is triggered every Monday at 9AM. It will randomize the list and then post it to our Teams channel. So, to get started we will a scheduled flow that repeats at 9AM:

Initialize Variables

I love that Flow has variables that you can use over and over and update. We need to create two string variables. The first will be our final ordered team list named Ordered Team:

Azure Functions to the Rescue

Now, I know that it sounds a bit silly to use a function for this, but why not! The nice thing is once it is published I will never have to update it again as I can update the flow if I have new members join the team. I can also automate sending the message to teams via flow and also adjust the schedule. It is a nice combo!

Calling the Function & Parsing Data

Now it is time to head back over to our Flow and make an HTTP POST to our function and pass it the Team data as the Body. If you desire to use my function I will let you :)

Post to Teams

For me I want to post the list to my Teams channel every Monday, so we need to create a tiny bit of HTML to post. We can do this by Appending to string variable each name in the list followed by a <br> tag on the Ordered Team variable we created earlier.

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9