Hey everyone, I’m trying to add a condition to a c...
# administration
r
Hey everyone, I’m trying to add a condition to a customer workflow. I have a multi-select field and trying to use the following condition - CASE WHEN INSTR({custentity25}, ‘OPTION 1’, 1) > 0 THEN 1 ELSE 0 END. It says it’s invalid expression. Any help would be great!
k
You need it to evaluate to true.
or false - so using a case statement doesn't quite process.
the way you have done it. Also there's probably more you want to do with it to ensure you don't get false positives.
TO_CHAR(INSTR({multiselect field}||',',{comparison field}||','))
The reason for the concatenation with commas (using pipes) is so that your string always ends in a comma, and your multiselect field ends in a comma - reducing the likelihood of a false positive (assuming your data doesn't contain commas)
so then your actual formula looks like this
TO_CHAR(INSTR({multiselect field}||',','OPTION 1'||','))>0
or
TO_CHAR(INSTR({multiselect field}||',','OPTION 1'||','))=0
then it will evaluate to true or false - which will trigger the workflow appropriately.
Of course - if you are using this in a client action (like a before submit check, or after field edit) then you have to use Javascript logic to perform the comparison
Here's a sample of something I did loading a customer record to compare their free shipping methods against the ship method on the sales order.
Copy code
(nlapiLookupField('customer',nvl(nullIfEmpty(nlapiGetFieldValue('entity')),-1),'custentity_po_free_ship_methods',false).concat(',')).

indexOf(nlapiGetFieldValue('shipmethod').concat(','))>=0
I have a whole write up I probably need to post as a blog at some point... cause man, that was fun to come up with.
r
Hey @KevinJ of Kansas thank you very much for the help!
k
So what did you end up doing
r
I was able to get a search to pull up the right fields selected and used that as my condition