Flowboost Multi-select Search Replace | Community
Skip to main content
cagarwal
New Participant
June 14, 2022
Solved

Flowboost Multi-select Search Replace

  • June 14, 2022
  • 1 reply
  • 3540 views

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.
Best answer by SanfordWhiteman

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*/

 

1 reply

SanfordWhiteman
New Participant
June 14, 2022

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(";");

 

cagarwal
cagarwalAuthor
New Participant
June 14, 2022

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 \.

 

CA
SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 14, 2022

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*/