Skip to main content
cagarwal
Level 3
Jun 14, 2022 7:31 AM UTC
Solved

Flowboost Multi-select Search Replace

FlowBoost has already impressed me with its potential since I started using it earlier this week. Thanks to Sanford and Etumos. I am wondering if there is a better way to achieve our goal with Flowboost's built-in functions to search/replace multi select values.

 

In searching the community, I came across this thread that shows full JS, but it appears that it could be much simpler with FBString.list.replaceAll()), although I'm not sure how to work with it. Below is an example:

 

Current Value of lead.fieldname: AA; BB; CC

  • Replace: AA with X;Y
  • Replace: BB with PQ
  • Replace CC with null

Final Value of lead.fieldname: X;Y; PQ;

 

Is there any recommendation on how to construct the Flowboost JSON payload template for this function?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Jun 14, 2022 7:17 PM UTC

Sorry, forgot a quirk about the webhook payload textbox.

 

You actually have to double-escape the regexp to have it sent correctly to FlowBoost:

 

/\\s*;\\s*/

 

7 replies

SanfordWhiteman
User Group Leader
User Group Leader
Jun 14, 2022 8:17 AM UTC

Hi Chirag, glad to hear you’re enjoying FlowBoost!

 

The FBString.list method was removed during a major version upgrade to FlowBoost (that thread is from 2016) because it was too specialized: you can do the same and much more with vanilla JS.

 

I’ve been meaning to publish a blog post with a bunch of different ways to work with multivalued (i.e. delimited string) fields in JS.

 

For your particular case, the JavaScript (it’s not JSON!) webhook payload you can use is:

let values = {{Lead.Your Multivalued String}}.split(/\s*;\s*/); values = values .map( value => value === "BB" ? "PQ" : value ) .map( value => value === "AA" ? ["X","Y"] : value ) .filter( value => value !== "CC" ); var multiValuedString = values.flat().join(";");

 

Translate
cagarwal
cagarwalAuthor
Level 3
Jun 14, 2022 11:11 AM UTC

Thanks @sanfordwhiteman ! 

 

Agree! A blog post would go a long way!

 

I tried this and got the following exception after calling the webhook. 

 

invalid escape '\s' not one of [\b, \t, \n, \f, \r, \\, \", \'] at index 74 in "let values = {{Lead.Americas Specific Communications - Daily (L)}}.split (/\s*;\s*/); values = values .map ( value => value === "Account & Financial Services" ? "AFA" : value ) .map ( value => value === "Professional Development" ? ["PD","Education"] : value ) .map ( value => value === "Consumer Goods & Services" ? ["CGS","Food","Beverage & Tobacco","Retailing"] : value ) .filter ( value => value !== "CC" ); var topicInterests = values.flat ().join (";");". Use \\ for literal \.

 

Translate
CA
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Jun 14, 2022 7:17 PM UTC

Sorry, forgot a quirk about the webhook payload textbox.

 

You actually have to double-escape the regexp to have it sent correctly to FlowBoost:

 

/\\s*;\\s*/

 

Translate