Skip to main content
Scheduled Maintenance: Trailhead, myTrailhead, and Trailblazer Community will be offline January 17, 16:00–20:00 UTC. Thanks for bearing with us as we update your experience!

Tempo estimado

Tópicos

Pergunte à comunidade

Assign First Selection to a Text Collection

It's time to start creating the gears that turn to do the work inside the manual loop. Let’s start with four things: a text variable, a text collection variable, a formula, and an Assignment element.

Resource or Element

Description

1

Text variable

You need a text variable (varCurrentAccount) to contain the current account ID in the manual loop. Remember how the Loop element has a “Current Item” variable that stores the record that's currently being processed by the loop? In this flow, varCurrentAccount performs the same function.

2

Text collection variable

You also need a text collection variable (txtcollSelectedAccounts) to store the selected account IDs together as structured data. This is our goal, remember?

3

Formula

To find the first account ID, use a formula (frmFindCurrentAccount) to isolate just the text of the first selection. This formula reads the varStringOfSelectedAccounts text variable and finds all of the text up to the first semicolon.

4

Assignment element

Because formulas don’t save data, you need an Assignment element inside the loop to store the formula’s result. The Assignment element:

  1. Copies the first selection's text to a dedicated text variable (varCurrentAccount). The flow needs to store this value separately, because the frmFindCurrentAccount formula’s value will change when the flow modifies varStringOfSelectedAccounts later.
  2. Adds the first selection’s text to a text collection variable (txtcollSelectedAccounts). This is how the flow copies the unstructured data into a structured variable.
  1. Create a text variable to contain the current account ID in the manual loop.
    • For Resource Type, select Variable.
    • For API Name, enter varCurrentAccount.
    • For Data Type, select Text.
    • Click Done.
  2. Create a text collection variable to contain all of the selected account IDs, together but separated.
    • For Resource Type, select Variable.
    • For API Name, enter txtcollSelectedAccounts.
    • For Data Type, select Text.
    • Select Allow multiple values (collection).
    • Click Done.
  3. Create a formula that finds the first selection.
    • For Resource Type, select Formula.
    • For API Name, enter frmFindCurrentAccount.
    • For Data Type, select Text.
    • For Formula, enter this text:
SUBSTITUTE(
   LEFT( {!varStringOfSelectedAccounts},
      FIND( ";", {!varStringOfSelectedAccounts} )
   ), ";", ""
)
    • Click Check Syntax to make sure the formula is valid.
    • Click Done.

Let's take a look at this formula. The spaces and line breaks aren’t necessary, but they help to visualize what's going on. To analyze the formula, start at the innermost formula function and work outward.

  • The FIND function looks for specific text in a text string and returns a number value indicating where it was found. In this case, it's looking for a semicolon in varStringOfSelectedAccounts. Remember, the flow uses semicolons to separate the IDs, so each semicolon marks the end of another ID. This FIND function finds that the first semicolon is the 19th character, so it returns the number “19”.
  • The LEFT function trims a text string down to a certain number of characters, starting from the left. In this case, it trims varStringOfSelectedAccounts down to 19 characters, because 19 is the value that the FIND function returns. What remains is the first record ID, something like 001B000000Qu2XxIAJ;
  • The SUBSTITUTE function replaces one group of characters with another group of characters. In this case, it looks at the remaining text (e.g. 001B000000Qu2XxIAJ;) and replaces the semicolon with “”. In other words, it eliminates the semicolon by replacing it with nothing.
  1. On the Not Null path, create an Assignment element that adds the current account to the text collection.
    • For Label, enter Add Current Account to Text Collection Variable.
    • Make sure the API Name is Add_Current_Account_to_Text_Collection_Variable.
    • In the first assignment row:
      • For Variable, select varCurrentAccount.
      • For Operator, select Equals.
      • For Value, select frmFindCurrentAccount.
    • Click Add Assignment and use these values in the second assignment row:
      • For Variable, select txtcollSelectedAccounts.
      • For Operator, select Add.
      • For Value, select varCurrentAccount.
  2. Save the flow.

But we're not done yet! This is just the first selection, and there are no elements that load up the next selection for you.

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback