Boolean 'OR' in DemandTools MassImpact formulas
07 May 2020
Table of Contents
Over on Salesforce Reddit, someone asked how to get “OR”-ing conditions together to work in a formula in the MassImpact module of Validity’s DemandTools ETL software.
The problem
They described their desired formula as being of the following structure:
IF(
OR(ThisCondition,ThatCondition)
,"ValueIfTrue"
,"ValueIfFalse"
)
They’d gotten this far with actual DemandTools code:
if_StringReturn(
{owner.profileid}="aaaaaaaaaaaa"
,"ValueIfTrue"
,"ValueIfFalse"
)
Failed guesses
I couldn’t get DemandTools to accept this:
if_StringReturn(
{owner.profileid}="aaaaaaaaaaaa" || {owner.profileid}="bbbbbbbbbbbb"
,"ValueIfTrue"
,"ValueIfFalse"
)
Nor did this (sometimes you can “add” trues & falses and they behave like 1’s & 0’s):
if_StringReturn(
(
{owner.profileid}="aaaaaaaaaaaa"
+
{owner.profileid}="bbbbbbbbbbbb"
) > 0
,"ValueIfTrue"
,"ValueIfFalse"
)
Winning code
So I kept playing with this idea of “adding” trues & falses until I finally came up with code that works:
if_StringReturn(
(
Int(
if_NumberReturn(
{owner.profileid}="aaaaaaaaaaaa"
, 1
, 0
)
)
+
Int(
if_NumberReturn(
{owner.profileid}="bbbbbbbbbbbb"
, 1
, 0
)
)
) > 0
,"ValueIfTrue"
,"ValueIfFalse"
)
Like the formula field editor in Salesforce, DemandTools doesn’t seem to care about your line breaks or whitespacing, so be sure to treat yourself to something nicely indented when writing a big formula like this.
Later-you will thank yourself.