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
Final Value of lead.fieldname: X;Y; PQ;
Is there any recommendation on how to construct the Flowboost JSON payload template for this function?
Solved! Go to Solution.
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*/
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(";");
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 \.
Thank you, Sanford. For some reason, I was unable to get it to work.
This is our payload template:
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(";");
This is payload with value (taken from Activity Log):
let values = "Account & Financial Services;Professional\u202FDevelopment\u200B;".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(";");
The response is:
{"topicInterests":"AFA;Professional Development;"}
While it did work for Account & Financial Services, it didn't pick up the matched value for Professional Development.
In another case, Accounting & Financial Services didn't match up when it was the only value in original token.
let values = "Accounting & Financial\u202FServices\u200B".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("; ");
Response:
{"topicInterests":"Accounting & Financial Services"}
It's possible I missed something in the configuration 🤔
Something’s clearly wrong with the original data. See the Unicode escape sequences here instead of spaces?
Account & Financial Services;Professional\u202FDevelopment\u200B;
U+202F is a Narrow No-Break Space. U+200B is a Zero-Width Space.
You aren’t matching on either of those so the behavior is expected. How are you loading data into those fields with such (relatively) obscure characters?
It is nothing out of the ordinary - we use a Marketo form to update the values. But I can see &ZeroWidthSpace in source
let values = "Professional\u202FDevelopment\u200B; Accounting & Financial\u202FServices\u200B; Energy &\u202FIndustrials\u200B".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(";");
Response (matching failed as expected with escape sequences)
{"topicInterests":"Professional Development; Accounting & Financial Services; Energy & Industrials"}
Field value
Professional Development; Accounting & Financial Services; Energy & Industrials
The bad characters are there on your form as well.
Check the URL-encoded output of your checkbox values:
Array.from(document.querySelectorAll("input[type=checkbox]"))
.forEach(function(cbx){
console.log(encodeURIComponent(cbx.value))
});
Professional%E2%80%AFDevelopment%E2%80%8B
Accounting%20%26%20Financial%E2%80%AFServices%E2%80%8B
Consumer%20Goods%20%26%E2%80%AFServices%E2%80%8B
Energy%20%26%E2%80%AFIndustrials%E2%80%8B
Financial%20%26%20Business%20Services
Healthcare%E2%80%8B%20-%20Biomedical%20and%20Pharmaceuticals
Healthcare%E2%80%8B%20-%20Healthcare%20Services
Real%E2%80%AFEstate%E2%80%8B
Tech%2C%20Media%2C%20%26%20Telecom%20-%20Media
Tech%2C%20Media%2C%20%26%20Telecom%20-%20Technology
Tech%2C%20Media%2C%20%26%20Telecom%20-%20Telecommunications