Tutorial
Quickstart
Build a validation set, a formula and a logic flow for opportunities, wire them to the Opportunity table with a recipe, and test them.
In this tutorial you build a small piece of sales logic from start to finish. You will check new opportunities for missing or impossible values, calculate their weighted revenue, and email the sales managers when a large opportunity is created. Along the way you use the main Logic Composer building blocks: a project, a validation set, a formula, a logic flow and a recipe. It takes about 30 minutes.
What you will build
Section titled “What you will build”| Artifact | Name | What it does |
|---|---|---|
| Project | Sales Rules |
Holds everything you build in this tutorial |
| Validation set | Opportunity checks |
Stops an opportunity from being saved without a customer, with no revenue, or with an impossible probability |
| Formula | Weighted revenue |
Calculates estimated revenue × probability |
| Logic flow | Notify sales managers |
Finds the members of the Sales Managers team and sends them an email about the opportunity |
| Recipe | Opportunity rules |
Runs the validation set and the flow when an opportunity is created |
Before you begin
Section titled “Before you begin”- Logic Composer and Logic Composer Tools are installed. See Installation.
- You have the Flowon Customizer security role.
- The environment has an unmanaged solution you can use for the project, for example a “Sales customizations” solution.
- A team named Sales Managers exists, its members have email addresses, and the environment can send email.
Create a project
Section titled “Create a project”-
Open the Logic Fabric Logic Composer app and go to Logic FabricSettingsProjects.
-
Select New.
-
Enter
Sales Rulesas the Project Name and choose your unmanaged solution in Solution. -
Save the project.
Every artifact you create next belongs to this project. You cannot move an artifact to another project after its first save.
Build the validation set
Section titled “Build the validation set”A validation set runs several named rules and reports every rule that fails. In a recipe, the names of the failed rules are the message the user sees, so write each name as the sentence you want users to read.
-
Go to Logic FabricLogicLogic Blocks and select New.
-
Enter
Opportunity checksas the Name and choose theSales RulesProject. -
In the editor, under What should this block work out?, choose Validation set.
-
On the Input tab, add three inputs:
Name Type Must have a value EstimatedRevenueCurrency Off ProbabilityWhole Number Off CustomerLookup to Account Off Leave Must have a value off: checking for missing values is the job of the rules.
-
Open the Validation Set tab and select Add rule for each of these rules:
Name Condition Estimated revenue must be greater than zeroIs Greater Than: EstimatedRevenue > 0A customer is requiredNot Null: Customer is not emptyProbability must be between 0 and 100Is Between: IsBetween(Probability, 0, 100)Build each condition in the expression editor by picking the function, then filling its slots with the input and a constant. The formula bar shows the result.
-
Leave Return First Validation Error off, so that every failing rule is reported.
-
Save the block.
Test it
Section titled “Test it”-
Select Run on the block.
-
Leave Customer empty, set EstimatedRevenue to
0and Probability to150, then select Run (or press Ctrl+Enter). -
The result shows the outputs: isValid is
falseand failedValidations lists the names of all three rules. -
Fill in a customer, a revenue above zero and a probability of
40, and run it again. isValid is nowtrue.
Build the formula
Section titled “Build the formula”-
Create another logic block named
Weighted revenuein theSales Rulesproject and choose Formula. -
On the Input tab, add
EstimatedRevenue(Currency) andProbability(Whole Number). Switch on Must have a value for both. -
On the Formula tab, set the result Type to Currency.
-
Select Write formula and build this expression:
Round(EstimatedRevenue * Probability / 100, 2)Pick Round, then fill its value slot with Divide, whose first value is Multiply (
EstimatedRevenueandProbability) and whose second value is the constant100. Set the digits slot to2. -
Save the block, then Run it with
500000and40. The result is200000.
The formula’s output is always named result. Because a Currency value is involved, the calculation keeps its decimals; see Data types for how number types combine.
Build the logic flow
Section titled “Build the logic flow”The flow uses two steps worth knowing: Resolve Recipients turns a team into a list of users, and Create Email creates and sends the email in one step.
-
Go to Logic FabricLogicLogic Flows, select New, enter
Notify sales managersas the Name and choose theSales RulesProject. -
On the Input tab, add two inputs, both with Must have a value on:
Name Type OpportunityLookup to Opportunity WeightedRevenueCurrency -
Open the Flow tab and select Add step. Search for
recipientsand choose Resolve Recipients. Name the stepSalesManagers, set Users From to Team and pick the Sales Managers team. -
Below that step, select Add step and choose Create Email. Name it
AlertEmailand set:Setting Value To Add Recipient > SalesManagers.Output.usersRegarding OpportunitySubject Format("Large opportunity: weighted revenue {0}", WeightedRevenue)Body Concatenate("Please review this opportunity: ", RecordUrl(Opportunity))Send the email now Selected Record Link (
RecordUrl) builds a link that opens the opportunity in the browser. -
Save the flow. The Needs setup marker disappears from the step cards.
Test it
Section titled “Test it”-
Select Run on the flow.
-
Pick an existing opportunity for Opportunity and enter
200000for WeightedRevenue. -
Select Run. The flow has no outputs, so a Succeeded banner is the result to look for.
-
Check that the members of Sales Managers received the email, and that it appears in the opportunity’s timeline.
Wire it up with a recipe
Section titled “Wire it up with a recipe”A recipe runs your logic when records of one table change. You will validate opportunities before they are created and, after creation, notify the managers when the weighted revenue is at least 100,000.
-
Go to Logic FabricLogicLogic Recipes, select New, enter
Opportunity rulesas the Name and choose theSales RulesProject. -
Under Which table does this recipe react to?, search for
opportunityand choose the Opportunity table. The table is fixed once the recipe is saved. -
On the Create card, use Select Properties to make these columns available: Opportunity, Est. Revenue, Probability and Account.
-
In stage 1 Validation, select Add validation. Choose
Opportunity checksas the Validation Logic Block and map its inputs:EstimatedRevenueto Est. Revenue,Probabilityto Probability, andCustomerto Account. -
In stage 3 After Create, select Add action. Set Action Type to Flow, choose
Notify sales managers, and map its inputs:Opportunityto the new record’s Opportunity column.WeightedRevenueto Run Logic Block >Weighted revenuewith Est. Revenue and Probability as inputs and result as the output.
-
In Applies When: for the same action, build the condition
Weighted revenue ≥ 100000the same way: Is Greater Than Or Equal To, with Run Logic Block on the left and the constant100000on the right. -
Switch on Async for the action, so the email is sent in the background and the user does not wait for it.
-
Save the recipe.
Try it end to end
Section titled “Try it end to end”-
In your sales app, create an opportunity without an account and with no estimated revenue. The save is cancelled and the message lists A customer is required and Estimated revenue must be greater than zero, one per line.
-
Create an opportunity for an account with Est. Revenue
500000and Probability40. The opportunity is saved, and shortly afterwards the Sales Managers receive the email. -
Create one with Est. Revenue
50000. It is saved, but no email is sent, because the weighted revenue is below 100,000.
Next steps
Section titled “Next steps”- Add the same validation to the Update card, so edits are checked too. See Recipes.
- Restrict who can run the flow with a precondition.
- Replace the hard-coded
100000with a configuration value so it can differ per environment. - Explore all flow steps and expression functions.
- Move the project to a test environment with the Logic Fabric CLI.