Professional Documents
Culture Documents
Using Formulas To Set Values Based On Values in Multiple Other Fields
Using Formulas To Set Values Based On Values in Multiple Other Fields
This tip explains how you can have Cumulus set the value in a metadata field based on the combined values of other
fields. So, for example, you can have an “Approved for Distribution” check box field that Cumulus automatically sets only
after an asset is approved and the embargo date has passed.
Canto, the Canto logo and Cumulus are registered trademarks of Canto. Other company and product names might be trademarks of their respective owners.
C|TIP/FormulaMultipleFields/V1.0/08.2009 Copyright ©2009 Canto GmbH. All rights reserved. www.canto.com Page 1 of 2
CUMULUS POWER TIP: Using Formulas to Set Values Based on Values in Multiple Other Fields
This statement tests to see if the Approval field is If “Approval” is checked and “Embargo Date” is in
checked, in which case it’s considered to have a the past, this test is true.
value of True.
Next comes the part of the formula in which we
NOTE: True and false are not case sensitive, so tell Cumulus what value we want it to use for
you can use true, True, false or False. You can either a true or false test result. We call this the
also use 1 for true and 0 for false, if you prefer. value portion of the formula. This formula’s value
section is very simple.
(The entire statement is surrounded by paren-
theses to isolate it from the other code.) First you see the question mark. This separates
the “test” portion of the formula from the “value”
The Boolean connector that follows (&&) indi- portion. This is standard for all Cumulus formulas
cates that another test follows, and it must also that include test and value sections.
be true. (|| would be used instead of && if either
of test being true was enough.) After the question mark comes the true and false
values that we want Cumulus to put into the
In the code that follows, the various sets of “Approved for Distribution” field:
parentheses are color coded so that it’s clearer to
you which parentheses are “partners.” (In com- ? True : False
puter programming, parentheses always come in If our test is true, set “Approved for Distribution”
sets of two.) FIGURE 3: If a product costs between 100 and 200,
to true (check it). If our test is false, set or that product is on sale, it becomes a featured
(fieldValue("Embargo Date") < now()) “Approved for Distribution” to false (uncheck it) product. Color boxes indicate test results.
Let’s remove the individual statements from this Like all formulas, this one will execute when the
line and just see the structure: asset is cataloged, and each time thereafter the Consider the following formula from a Boolean
asset record is updated. field called “Featured Product.” It tests whether
(this < that)
an item is priced between 100 and 200, or
Now it’s easier to see what’s happening: This is whether the item is on sale. If either of these con-
Do Even More with the Formula.
less than that.” If this is less, then the entire state- ditions is true, this test passes and “Featured
The primary benefit of this document is to show
ment becomes true. But if that is less, then the Product” gets a true value.
you how you can test the values of multiple fields
statement is false. in your formulas. So, if you need to do tests of (
Now, let’s put the original statements back in: three or more fields, just use the same tech- (fieldValue("Price") >= 100)
niques, adding more parentheses where needed. &&
fieldValue("Embargo Date") < now()
Examples: (fieldValue("Price") <= 200)
First off, now() is a built-in Cumulus function )
that returns the current date and time. So, what “True” result in three tests ||
we’re doing in this line is comparing the value in (Test 1) && (Test 2) && (Test 3) (fieldValue("On Sale") == True)
the Embargo Date field to the current time. If ? True Value : False Value ?
now() is larger, that means the Embargo Date True : False
“True” result in either of two tests
has passed.
(Test 1) || (Test 2) Figure 3 shows this setup on a Details view.
Finally, we wrap that entire line back into its own ? True Value : False Value
set of parentheses (the red ones) so that NOTE: If a multi-conditional formula is not
“True” result in two tests, or “true” in a third working, pay extra careful attention to your
Cumulus can consider it as a whole.
((Test 1) && (Test 2)) || (Test 3) parentheses sets. Make certain parentheses
So, now let’s look at the entire “test” portion of ? True Value : False Value appear in sets, and in the correct positions.
the formula again:
Keep in mind, each test used in a formula can
(fieldValue("Approval") == True) && check for values in different fields, or they can
This Power Tip is intended to work in all editions of
check for value ranges in a single field. (Or combi-
(fieldValue("Embargo Date") < now()) Cumulus 7.5 and later.
nations thereof.)
Let’s read it as Cumulus does:
Canto, the Canto logo and Cumulus are registered trademarks of Canto. Other company and product names might be trademarks of their respective owners. Some product
claims and features are not included in all versions of the software and/or might require additional Cumulus Add-ons or Plug-ins.
C|TIP/FormulaMultipleFields/V1.0/08.2009 Copyright ©2009 Canto GmbH. All rights reserved. www.canto.com Page 2 of 2