Вы находитесь на странице: 1из 2

CUMULUS POWER TIP:

Using Formulas to Set Values Based on Values in Multiple Other Fields


Canto Cumulus can make “smart” metadata value decisions based on the current values of 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.

Logic Overview. NOTE: Though useful as explained here, the


This formula automatically determines when an real power of a formula process like this
asset can be distributed, based on this rule: comes from being able to specifically deter-
mine which users can modify the Approval
The asset must be approved and the embargo date
and Embargo Date fields, which you can do
must have passed. with Cumulus Enterprise, Complete and
To turn this rule into Cumulus automation, we upgrade Workgroup systems. That way, you
need three metadata fields: know when the approval is granted, it was
authorized. Contact your Canto representative
• Approval — We’ll make this a Boolean field, for information on upgrading Workgroup and
which appears to users as a check box. When
Entry systems with this functionality.
the asset is approved, someone checks the
box.
The Formula Breakdown.
• Embargo Date — We’ll make this a Date field. Our formula, as shown in figure 2, isn’t compli-
The asset must not be distributed—even if cated once you break it down. As with most
approved—until this date has passed. Cumulus formulas, the core structure is:
• Approved for Distribution — This Boolean
Test ? True Value : False Value
field will be automatically checked (or not) by
our formula, based on the values in the other This means, if Test is true, use the True Value.
two fields. This is also the field that contains Otherwise, use the False Value. No matter
the formula. how complex a Cumulus formula first appears, it
always follows this structure. FIGURE 2: When entering longer formulas, it can be
Figure 1 shows how these fields might appear
inside an Information Window. helpful to split things onto separate lines to improve
In our formula, we’re testing the values in the readability. Cumulus ignores returns, so feel free to
Approval and Embargo Date fields. In other make things easier on yourself!
words, we’re testing two separate conditions. In
order for the True Value to occur, both of these In case you want to better understand this logic,
“sub tests” must be true. If either is false, the consider the question: How are your parents?
False Value is used.
In order to answer, you have to think about the
condition of each parent. “Great!” works only if
both parents are doing well. If either (or both) are
Why use two equal signs? not well, “great” is not true.
Some math operators are represented by
two characters in computer code, including: This concept in mind, take another look at our
formula structure:
• <= (less than, or equal to)
Parents Are Okay ? True : False
• >= (greater than, or equal to)
FIGURE 1: In a real world situation, the Approval • != (not equal to) Is “Parents Are Okay” a true statement? If so,
and Embargo Date fields might be on separate true applies; otherwise false applies.
views, each available only to certain users. This • == (equals)
highlights one advantage of having Cumulus make Our condition is similar in that we need a “true”
the final determination—it “sees” all values. Boolean connectors also use two characters:
result for the tests of both our test fields
• && (and) (“Approval” and “Embargo Date”) in order to
If approval has been granted, and if the embargo • || (or) mark the asset “approved for distribution.”
date has passed, our formula marks the asset
Greater-than and less-than use only a single Let’s take a look at the first part of the formula:
“Approved for Distribution.”
character: > and <
(fieldValue("Approval") == True)

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:

About Canto & Cumulus For more information, contact your


Canto has been dedicated to helping customers fully utilize their digital assets since 1990. local Canto partner, or Canto:
Canto Cumulus is a cross-platform solution that enables companies to easily organize, find, In the U.S.
share and track their ever-increasing numbers of digital files, in any format. Canto’s worldwide +1 (415) 495-6545
network of certified developers offers an impressive assortment of plug-ins that enhance the
Cumulus product line further. In the E.U.
+49 (0) 30 390 485 0
Learn more: www.canto.com
Everywhere
info@canto.com

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

Вам также может понравиться