Build Tests Automatically with Flow Test Builder

This extension includes a flow that will generate Apex test classes for a selected target flow. A good example and use case is shown in this video:

Autolaunched Flows can be launched via a REST or Apex call. That means that you can create tests that invoke the flows, passing in specified inputs, and inspect the outputs from the Flow to see if it’s returning the expected result.

This Flow Autotest package installs a flow called Flow Test Generator. When you run it, you’re asked first if you want to Add, Edit or Delete a FlowTest. FlowTest is a Custom Object that stores the information specific to one test and its assertions:

Creating a new test involves first selecting the target flow, which must be an Autolaunched flow:

For each test, configure the desired combination of flow input values:

Then define the tests you want to run on the resulting flow output values:

The test class will then be generated. At this time, you have to add it manually to your org using Developer Console.

Install

Prerequisite: This app requires Flow Actions Base Pack (v3.11+) and Flow Screen Components Base Pack (3.0.18+). You can install them here.

2/26 V3.0 Production Sandbox – Works with V3 Action and Screen Components Base Pack versions.

Source Code

view source

Old Versions

Version 1.0.2 Unlocked 9/3/21

Version 1.0 Unlocked 7/19/20

Introducing Flow Base Components

NOTE: The Flow Base Components package has been superseded by the Flow Action BasePack and Flow Screen Component Base Pack. If you’re a developer, use those as your prerequisites.

Most components available on UnofficialSF now use the Actions Base Pack and Screen Components Base Pack, described above. A few existing older components still use and require the original Flow Base Components.

As more Flow extensions get built, some components are proving to be popular and reused. To manage this more effectively and minimize conflicts that prevent installation, we’ve created this single base component library. If you want to use one of these components, we recommend that you make this package a dependency and reference the components here. This will help ensure your extension can be easily installed.

There isn’t going to be a managed package version of this because that would put the lightning components into a custom namespace, and lwc doesn’t currently allow lightning components to be used across namespaces

The current components included in Flow Base Components are:

Expression Builder

A full expression builder. Generates formula strings for output, and these can be evaluated at runtime by the Evaluate Formula action, which is part of this package.

Reference

Flow Combobox

This is essential for any custom property editor. It provides a picklist showing upstream merge fields.

Reference

Formula Builder

A full formula builder. Generates formula strings for output, and these can be evaluated at runtime by the Evaluate Formula action, which is part of this package.

Reference

Object and Field Picker

Provides a drop in component for selecting Objects or Object/Field combinations.

Reference

Show Toast

A simple local action that pops a toast up. Works with Screen flows only.

Learn more.

Transfer Metadata

A screen component that can retrieve or deploy any salesforce metadata.

Learn more.

Quick Choice

Learn more here.

Dual ListBox

Learn more here.

Usage Notes

All of the classes and components in this repo have been given a prefix of ‘fbc_’ this looks a little like a namespace but it is not. This is an unlocked package in the c namespace.

For sample code showing how to reference these, take a look at Update Field, a Flow Action that makes extensive use of this base component package. Here are some examples:

Referencing a base screen component

Pay particular note to the mixed use of hyphens and underscores:

Referencing a class method

Referencing methods and components from an lwc

Note the different syntax:

Install

1.3.4 Unlocked

10/4 fixed test bug.

Version Information

1.3.3 Unlocked 10/1 fixes QuickChoice naming conflict

1.3.2 Unlocked 9/26 Adds QuickChoice and DualListBox. Also reduces the size of the MetadataService file to avoid the ‘1 million character’ limit.

1.2.6 Unlocked
9/3/20 – Eric Smith – Updated to Escape and Unescape the {} characters so the metadata string value can be handled by a flow

1.2.5 Unlocked 9/1
9/1/20 – Eric Smith – Added Extracted Metadata String and Escaped Metadata String outputs to the RetrieveMetadata and the TransferMetadata components

1.2.4 bug fixes

1.2.3 bug fixes to Flow Combobox

1.2.2: improvements to Transfer Metadata

In version 1.2.1, Flow Base Components gains:

  • Transfer Metadata
  • Show Toast

Flow Base Components already contains:

  • Expression Builder
  • Formula Builder
  • Flow Combobox
  • Pick Object and Field

View Source

source

Old Versions

1.2.4 Unlocked 8/21

1.2.3 Unlocked 8/5

1.2.2 Unlocked 7/26

1.2.1 Unlocked 7/25

from Chris Emmett: A Great 1 Minute Intro to Loops

Probably destined for the Academy Award for 2020 for Best Flow Short. Check it out!

From Jenn Lee: Use Flow to Create Users and Manage Permission Sets and Permission Set Groups

This solution features a neat use of Custom Metadata Types to store sets of related values for user creation. Check it out!

Add a Rich Text Input Control to your Flow Screens

This Post was most recently updated on: 4/16/23


Key Contributors: Nick Sauer, Clifford in Frankfurt

4/16/23: Thanks to Clifford in Frankfurt, this extension now fully supports the ability to enable or suppress specific formats

Input Rich Text sports a nice toolbar and allow rich text creation. It also provides Find and Replace, Autoreplace, and Blocklists. As you can see below, these new features are available via a swanky bottom toolbar, and can be turned on or off as a group. Clifford in Frankfurt has added additional ability to control which features are enabled or suppressed.

Note that this isn’t the only choice you have. Here’s a powerful alternative extension to consider, with a different mix of features.

You can pass in a map of terms that you want to automatically replace.

How it Works:

Use Case Example:  Business has the need  to enter customer-facing details that:

  1. Blocks users from entering certain sensitive words/symbols
  2. Automatically applies Trademarks (™) or other company-specific terminology.
  3. Allows for Find & Replace tool to correct mistakes

Summary:

IMPORTANT: Use enabledAdvancedTools = true input attribute if you want to leverage these enhanced features. Otherwise leave empty and regular input Rich Text component will be used.

  1. Warn or Block Transition in Flow if disallowed words and/or symbols are present.
  2. Find and Replace
  3. Auto-Replace suggested words
  4. Undo functionality for search/replace or suggested words
  5. Character Count and Max Character limits.

Admin Instructions:

Enabling and Disabling Features in Flow:
  1. Default function is regular rich text input field. To enable advanced features set enableAdvancedTools to true.
  2. Setting label provides a field label for the rich text input.
  3. Rich Text input/output is provided through the value attribute.
Configure the default Rich Text Features in Flow:
  1. By default, all rich text features (called formats) like bold, italic, image etc. are enabled.
  2. Optionally, specify the exact formats you want to allow by providing a comma-separated list with formats to the “Enabled Formats” attribute. Example: bold, image
  3. Optionally, disable certain categories by providing a comma-separated list with categories to the “Disabled Categories” attribute. Example: INSERT_CONTENT, ALIGN_TEXT
  4. The complete list of formats and categories can be accessed in the Input Rich Text documentation on: https://developer.salesforce.com/docs/component-library/bundle/lightning-input-rich-text/documentation
Replace Text with Suggested Terms:
  1. If autoReplaceMap is populated, then a button is shown to user.
  2. Use autoReplaceMap to set up key:value pairs in JSON. Example: {“Test”:”GreatTest™”} a. When user employs the button, the key will be replace by value.
Managing Disallowed Words and Symbols:
  1. If disallowedSymbols or disallowedWords is filled, then user will be notified while typing one of those words or symbols.
  2. Both disallowedSymbols and disallowedWords accept a comma delimited string.
  3. The default message will say ‘Error’ and provide the violating word/symbol. This will also give validation error if user tries to advance while error is still present.
  4. To change the message to a warning only, and turn off the associated validation (allowing user to advance the Flow), set warnOnly attribute to true.
Character Counts and Limits:
  1. Character count is off by default. Set characterLimit to an integer value to show character count and limit.
  2. If warnOnly is not set when characterLimit is on, then the Flow Next/Finish cannot be used until resolved.
ParameterIOInformation
enabledFormatsXAn optional comma-seperated list of allowed formats. By default, the list is computed based on enabled categories. Example: bold, image
disabledCategoriesXAn optional comma-separated list of button categories to remove from the toolbar. Example: INSERT_CONTENT, ALIGN_TEXT
enableAdvancedToolsXBoolean. Set to true if you want to use enhanced rich text. Default is false (regular input component)
autoReplaceMapXJSON formatted key:value map. (example => {“Test”: “GreatTest™”} )
disallowedSymbolsXComma-separated list of words to block. Example: /,@,*
disallowedWordsXComma-separated list of words to block. Example: bad,worse,worst
warnOnlyXBoolean. Set to True if you want to allow Next even where disallowed Symbol or Word remains. Default is false.
characterLimitXInteger. Set character limit. This will enable character count and limit, and if warnOnly is not true, then will block next.
valueXXInput and output Rich Text that you’ll be editing
labelXXInput to provide field-level label if desired

User Instructions:

  1. While entering text in the Rich Text Area, if you use words or symbols that are flagged as not allowed, you will receive either a warning message or an error message. a. If the warning message is displayed, this is for notification only, and you will be able to proceed. b. If the error message is shown, this means you will need to correct the noted error prior to continuing. If you try to click Next/Finish, a validation message will be given.
  2. To Search and Replace text, click on the magnifying glass icon. titled ‘Search and Replace’ a. A ‘Search Text’ field is displayed where you enter the text you want to find. b. A ‘Replace with Text’ field is shown where you enter the replacement text to be applied where the ‘Search Text’ is found. c. Use the ‘Check’ icon to commit the search/replace. d. Use the ‘Revert Last Change’ button that appears after search/replace to undo the changes just made. e. If you no longer want to use Search/Replace, you can click on the Magnifying Glass icon again to hide these fields.
  3. To replace suggested terms set up by your admin, click on the Merge icon titled ‘Apply Suggested Terms’. Note this will only be shown if your admin has configured this. a. The component will find text to be replaced and overwrite with teh replacement term identified by your admin.
    b. Use the ‘Revert Last Change’ button that appears after search/replace to undo the changes just made.

Component Input Example:

Installation:

1.5 Unlocked 4/16/23 Production Sandbox – Additional support for turning on formats

Resources:

Source

Also see https://unofficialsf.com/copy-paste-of-images-in-flow/

Old Versions

1.4.1 Unlocked 7/3/21 (Production or Dev) 7/3/21 – Eric Smith – Added an * next to the Input Label when the Required attribute is True
1.4.1 Unlocked 6/3/21 (Sandbox)

1.4 Unlocked 6/25/21 (Production or Dev)
1.4 Unlocked 6/25/21 (Sandbox)

6/25/21 – Eric Smith – Added a Required attribute and adjusted the bottom margin to better match standard components

1.3 Unlocked 8/1/20

1.0.1

MetadataService: A Useful Base Library for Flow Developers

MetadataService is a subset of Andy Fawcett’s legendary Apex-Mdapi metadata service project, slimmed down and packaged to be useful to Flow Developers as a dependency.

If you’re using these metadata deployment and retrieval services in your own Flow Action or Screen Component, consider simply requiring that this package be installed as a prerequisite

Learn more here.

Installation

V1.0 Unmanaged 7/5/20

Source

source

Developer Memo: Working With Metadata Service

There are some powerful data structures that are currently available only through retrieval and deployment via the metadata API. For example, the Process Builder Converter tool works by first retrieving a process builder process as a piece of flow metadata, then editing the metadata so it can be opened in Flow Builder, and then deploying the modified flow metadata as a new, separate flow.

In general, using metadata deployment and retrieval is the last resort you should use. If your data is accessible via the UI API, the Tooling API, or via a REST interface, those are likely to be preferable. One reason is that metadata deployment may trigger a recompilation of all of the apex classes on your org, and that will pause your deployment until it’s finished. So while metadata deployment will generally go very quickly on developer edition orgs, it might be much slower on a production org. (As a note, you can control whether your metadata deployments trigger a recompilation with this checkbox:

Despite these issues, sometimes Metadata deployment is a great tool to use. The Process Builder example is a good one.

Another example involves creating, editing, and deleting ListViews via a Flow Action. While ListViews can be read via UI API and REST, they can only be created, edited, or deleted by doing metadata deployment of ListView metadata.

How to Incorporate Metadata Deployment and Retrieval

There are two sets of tools you can use to build Flow Actions and Screen Components that use Metadata Deployment and Retrieval.

Method 1: Assembling your Metadata Using Andy’s Objects

The first tool is the legendary Apex Metadata Service created by Andy Fawcett. This abstracts a lot of gnarly SOAP transactions into nice clean API’s. Here’s an example of a Flow Action making use of the Metadata Service to create ListViews:

The reason this works is that MetadataService has gone and created a wrapper class for each piece of Salesforce metadata. In the code above, you can see that we’re able to reference MetadataService.ListView(). Once we have one of the ListView objects, we can simply fill it with updated values, and then call createMetadata on it. There are similar methods for updating, deleting and reading.

You can peruse the vast set of available objects by scrolling through the main class file here.

Method 2: Assembling Your Metadata By Hand

When we went to create the process builder converter, though, we weren’t able to use the above method. The reason is that the current MetadataService only has updated metadata through API version 42, from 2017. We needed to create flow metadata that used brand new additions that had only been added in version 48.0

You can see here, that the Flow definition in Metadata Service (era 2017)…

lacks the brand new metadata element that stores new Flow triggering information:

Hopefully, someone will update the MetadataService to the latest API. In the meantime, you can solve this problem because the MetadataService also provides direct access to lower level deploy and retrieve methods that don’t require you to populate one of the metadata objects.

When you operate at this lower level, you have to directly parse and modify the metadata xml. Then you have to zip it up with base 64 encoding, and then you call MetadataService’s ‘deploy’ method directly. This has been implemented asynchronously, so we carry it out via a Flow screen component called TransferMetadata that can sit there on a flow screen and poll until a response is received.

While this may sound a little intimidating, you can just take and copy the code we used.

Introducing the MetadataService BaseLibrary

To streamline the efforts of developers who want to build tools like Create or Edit ListViews, we’ve packaged the necessary MetadataService files into a useful package that you can just require as a dependency. This package leaves out some extraneous files from the repo but has everything necessary to carry out deployment and retrieval.

In general we’re starting to move towards base libraries to avoid collisions and simplify packaging for new actions and developments.

Install it here.

Create or Update with the new ‘Upsert Records’ Action

Use UpsertRecords when you want to take a collection that may or may not already exist in the database and save it. If the records in the collection have valid Id values, the corresponding records in the database will be updated with the flow’s collection. If not, new records will be created and saved.

UpsertRecords provides functionality similar to the Apex ‘upsert‘ command. You can optionally provide the name of a field on your object that is the externalId and you can specify that you want partial saving to work even if some of the saves fail (‘all or none’).

This functionality is available in the CollectionActions package starting with version 1.19.2

You can provide either a collection or an individual record (and in fact can provide both), but because of a limitation in the action configuration framework, you have to specify both types, even if you’re only using one, like this:

Inputs and Outputs

AttributeType
inputCollectionList<SObject>
inputRecordSObject
externalIdFieldNameString
allOrNoneBoolean

This action currently has an output called ‘placeholder’ that should just be ignored. If an error occurs during the upsert, the error message will be thrown back to the flow

Installation

Install the Collection Actions package, starting with 1.19.2