Make Use of the Platform Cache from Flow

Salesforce provides a Platform Cache that can serve as a temporary storage device for your data. One use of this is when you want to store some data with one flow and retrieve it with another. However, caches are intended only for data that doesn’t need to sit around for long. They’re not intended to be used for persistent, reliable storage. For that, create a record and store your data in the record.

Another benefit of caches is performance. If you have a set of values that lots of your flows are constantly loading, you can potentially speed up your flow performance and reduce your number of DML operations by getting those items from your cache.

This package provides two Flow Actions: Store Data in Cache and Get Data From Cache.

Store Data in Cache

This action can store multiple pieces of data simultaneously in the cache. It has inputs for Records, Record Collections, Strings, Dates, and DateTimes. In each case, provide a key string that you’ll use when retrieving the data. You can use the cacheType input to specify whether you want to use your Org cache or a user Session cache (it defaults to Session).

Note that you need to specify an object type for the Record and Record Collection inputs even if you have no interest in caching records. That’s just a limit of the current UI.

In the following example, two pieces of data are being cached: a date and a string.

Get Data From Cache

This action allows you to specify one key only, so you’re only going to get one piece of data out per call.

Note that you need to specify an object type for the Record and Record Collection outputs even if you have no plans to retrieve records. That’s just a limit of the current UI.

Preparing Your Org

You can enable a scratch org for platform cache by adding ‘PlatformCache’ to your project JSON.

On a normal org, note that these actions do not currently support namespaces and named partitions. They assume the use of the default partition. Read about Platform Cache for more information. Here’s an example of an org with a default partition that’s ready to work with these actions:

There are some other cache features like setting the expiration time that are not currently supported in these actions, but can be added if there’s interest.

Install

Version 1.0.0 Unlocked

View Source

source