Hi all, we have a Solution Engagement field to keep track of all the products that prospects are engaged with. I'm already using this sort of workflow to populate new products into the Solution Engagement field: Handling Multi-Select Fields in Salesforce
But what I want to know is, how can I de-select a value that's already populated on a prospect's record? For example, if a sales person calls the prospect and decides they're not a good fit for Product A, how do I remove that value from the Solution Engagement field without nulling out other values in that field? (i.e. I don't think I can just say Change Data Value, change to NULL). Thanks!
The way to do this is via webhook, which can parse semicolon-delimited (or anything-delimited) strings and return them with certain values excised.
Sanford, this is great - do you have an example of how this is done? Haven't parsed things in this way before. Thanks!!
<?php
if(isset($_POST['data']) && isset($_POST['var'])){
$data = $_POST['data']; // e.g. ";;product a;product b;;product c;;;;product d;product c;;product a; product a"
$var = $_POST['var']; // e.g. "product c"
$data = array_unique(array_filter(explode(";",$data))); // cleans up extra ; and duplicate values e.g. "product a;product b;product c;product d"
unset($data[array_search($var, $data)]); // removes the option from the multi select data
echo json_encode(array("response"=>implode(";",$data)));// map 'response' to update multi select field
}
?>
Gettin' there.
<?php
$purchases = "39;44;21;0;89";
assert( implode(array_filter(explode(";",$purchases)),";") == "39;44;21;0;89" ); // assertion failed
No embedded string values should be special in parsing. "0" is coerced to boolean false in PHP.
<?php
if(isset($_POST['data']) && isset($_POST['var'])){
function chkVar($value) { return ($value !== null && $value !== false && $value !== ''); }
$data = $_POST['data']; // e.g. ";;product a;product b;;product c;;;;product d;product c;;product a; product a"
$var = $_POST['var']; // e.g. "product c"
$data = array_unique(array_filter(explode(";",$data),'chkVar')); // cleans up extra ; and duplicate values e.g. "product a;product b;product c;product d"
if(in_array($var, $data)){unset($data[array_search($var, $data)]);} // removes the option from the multi select data e.g. "product a;product b;product d"
echo json_encode(array("response"=>implode(";",$data))); // map 'response' to update multi select field
}
?>
I'll trust ya that it's working now.
But this is a great case of PHP showing its clunkiness and lack of fluency (in both senses of the word!).
Which is why I'd do it like this:
How are you triggering the data value changes flow?
i.e. how are you selecting which value inside the multi picklist to take out?
or is this data hygiene that you'd run manually?
Anyway here's a php webhook that does the trick:
<?php
if(isset($_POST['data']) && isset($_POST['var'])){
$data = $_POST['data']; // e.g. "product a;product b;product c;product d;"
$var = $_POST['var']; // e.g. "product c"
$response = preg_replace( "/$var\;/", "", $data); // gives "product a;product b;product d;"
echo json_encode(array("response"=>$response)); // In Marketo map 'response' to update multi select field
}
?>
Will both false positive and mangle output on partial match, you must split on the delimiter
Hi Jessica,
You can perfectly say Change value ABC=NULL. This should work - I am doing it all the time
Helen
Hi Helen! But won't that null out ALL values? If I have A;B;C as values, I only want to take away A, leaving B and C...
Oh I see. No, that won't work then. How do you store the values? In the text area?
Yes - in this format - A;B;C which then checks the relevant values in the Salesforce multi-select picklist. Can't for the life of me figure it out! May need to handle in Salesforce.
I would suggest considering creating custom fields for A, B, C and keep them updated dynamically. If you need to keep them in one field, then you can use tokens to concatenate and update the target field. Multi-select is not well supported by Marketo. Building all the choices seem too much pain.