In Admin's Corner, Blog, Click vs. Code

Select Multiple Users for a Chatter Mention in Salesforce Flow

This may shock some of you, but I’m a big fan of Flow. It’s an amazing tool that can replace some apex code functionality with a declarative (no code) feature.

Unfortunately, this tool can have a bit of steep learning curve and be very frustrating for many experienced admins. Part of the issue is that Flow, while requiring no code, does require you to THINK like a coder. It also uses words like “Constant” and “Variable” which are programming terms. If you’re interested in getting started, you check out my Flow videos:¬†https://www.youtube.com/watch?v=y2OghQsE35k&ab_channel=BrianKwong

On top of these issues, sometimes Flow can simply be aggravating logical nightmare that makes you want tear your hair, fall to your knees, and scream into the falling rain. One example of this frustration is how Dynamic Choices and their stored values are treated within a Flow itself.

Building the Chatter Mention in Flow

Here’s an example. Over at Better Partners I am working with a customer who wants to be able to select users in a Flow screen and mention them in a chatter post. The easy way to build this is provide a screen with a single picklist with the User as the value. Then when the flow launches, the person selects User1 to mention and clicks next. The next screen asks if they want to choose another and if yes, redirects them to the start of the Flow. In the meantime we’re saving each selection in a collection or a variable for later use.

While this is the easier way to build it as an Admin, it is a terrible user experience. So many clicking. So many repeats. Bleh. Ick. Patooey.

So my alternative was to replace the single picklist, with a multi-select checkbox. We will still use a dynamic choice to populate the information. When the person selects multiple users on 1 screen, the values are saved in 1 place with a semi-colon separating each value. This SHOULD have been a simple matter of using a formula to strip out the semi-colon and replace with text to mention the selected users.

Unfortunately, Flow tossed a wrench. In the dynamic choice, my label is the User Name and the stored value is the ID. My expectation would be that referencing this would give me a bunch of UserIds separated by semi-colons. It turns out, it depends on how it’s referenced.

When I use the Screen Input field within a formula, I get the Name (label) and not the ID (stored value). But if I use a variable and set the value to be the screen input field, I get IDs.

First Line is just the Screen Input field using the Dynamic Choice. The 2nd is a variable where the default value is the Screen Input field.

This makes no sense! Both items are referencing the screen input field. Once directly and once with the screen input in a variable. This is one of those things you expect 1=1.

You would think that this discovery would make thing easier. Just use the variable in your formula. Right?

Nope!

flow formula

You can see I tried 2 different formulas. First one I’m just referencing the Screen Input. The second formula uses the variable instead. I’m not surprised that my first formula doesn’t work. I get Names with the screen input. I’m using the screen input. I expect names. I was incredibly frustrated with my second formula. It appears the variable gives me Ids. I’m using that variable. I expect IDs. Instead I get Names.

Finally, I figured out to make this work. It’s a incredible headache.

  1. Dynamic Choice looking up users. The label is the Name. The stored value is the User ID
  2. Screen with a multi-select checkboxes to select multiple users at one time. The screen input is named “{!Screen_Input}”
  3. Variable “{!vrIDs}” that has a default value of “{!Screen_input}”
  4. Variable “{!vrIDsTxt}” that has a default of “.{!vrIDs}”
  5. Formula “{!vrfMention}” that takes the {!vrIDsTxt} and replacing the semi-colon and the added period to format for a chatter mention

List of all outputs

 

And BOOM! I’m all set. Now I just need to reference my formula in a chatter post and I’ll successfully mention the people that were selected in my flow screen.

The actual formula looks like this:¬†SUBSTITUTE(“@[“+SUBSTITUTE(SUBSTITUTE({!vrIDsTxt}, “;”, “] @[“),”.”,””)+”]”,” “,””)

That gets rid of the period & semi-colon while adding the @ and [] for the chatter mention.

Conclusion

There we go. We can successfully create a chatter post. All it took was a dynamic choice, 2 variables and a formula. In an ideal world, it should just be a dynamic choice and 1 formula.

But it works.

What do you think? Can think of an easier way to meet this use case? Do you have any other odd Flow behavior? Let me know in the comments!

Don’t miss a post! Sign up to receive email notications.

Subscribe

Subscribe to our mailing list

* indicates required
I want to receive email notifications about:

I run this site, the podcast, and my training videos for the community. I do incur some costs. I greatly appreciate if you can help me out by checking out my affiliates and – if you shop amazon – start your search on my site.

Recommended Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Start typing and press Enter to search

Salesforce Lightning Roadmap Feature Image