using formulas to set values based on values in multiple other fields
TRANSCRIPT
-
8/14/2019 Using Formulas to Set Values Based on Values in Multiple Other Fields
1/2
Canto, the Canto logo and Cumulus are registered trademarks of Canto. Other company and product names might be trademarks of their respective owners.
Page 1 of 2C|TIP/FormulaMultipleFields/V1.0/08.2009 Copyright 2009 Canto GmbH. All rights reserved. www.canto.com
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.This formula automatically determines when an
asset can be distributed, based on this rule:
The asset must be approved and the embargo date
must have passed.
To turn this rule into Cumulus automation, we
need three metadata fields:
Approval Well make this a Boolean field,
which appears to users as a check box. When
the asset is approved, someone checks the
box.
Embargo Date Well make this a Date field.
The asset must not be distributedeven if
approveduntil this date has passed.
Approved for Distribution This Boolean
field will be automatically checked (or not) by
our formula, based on the values in the other
two fields. This is also the field that contains
the formula.
Figure 1 shows how these fields might appear
inside an Information Window.
If approval has been granted, and if the embargo
date has passed, our formula marks the asset
Approved for Distribution.
NOTE: Though useful as explained here, the
real power of a formula process like this
comes from being able to specifically deter-
mine which users can modify the Approval
and Embargo Date fields, which you can do
with Cumulus Enterprise, Complete and
upgrade Workgroup systems. That way, you
know when the approval is granted, it was
authorized. Contact your Canto representative
for information on upgrading Workgroup and
Entry systems with this functionality.
The Formula Breakdown.Our formula, as shown in figure 2, isnt compli-
cated once you break it down. As with most
Cumulus formulas, the core structure is:
Test ? TrueValue : FalseValue
This means, if Test is true, use the TrueValue.
Otherwise, use the FalseValue. No matter
how complex a Cumulus formula first appears, italways follows this structure.
In our formula, were testing the values in the
Approval and Embargo Date fields. In other
words, were testing two separate conditions. In
order for the TrueValue to occur, both of these
sub tests must be true. If either is false, the
FalseValue is used.
In case you want to better understand this logic,
consider the question: How are your parents?
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
not well, great is not true.
This concept in mind, take another look at our
formula structure:
Parents Are Okay ? True : False
Is Parents Are Okay a true statement? If so,
true applies; otherwise false applies.
Our condition is similar in that we need a true
result for the tests of both our test fields
(Approval and Embargo Date) in order to
mark the asset approved for distribution.
Lets take a look at the first part of the formula:
(fieldValue("Approval") == True)
FIGURE 1: In a real world situation, the Approvaland Embargo Date fields might be on separate
views, each available only to certain users. This
highlights one advantage of having Cumulus make
the final determinationit sees all values.
FIGURE 2: When entering longer formulas, it can behelpful to split things onto separate lines to improve
readability. Cumulus ignores returns, so feel free to
make things easier on yourself!
CUMULUS POWER TIP:
Using Formulas to Set Values Based on Values in Multiple Other FieldsCanto Cumulus can make smart metadata value decisions based on the current values of other fields.
Why use two equal signs?Some math operators are represented by
two characters in computer code, including:
= (greater than, or equal to)
!= (not equal to)
== (equals)
Boolean connectors also use two characters:
&& (and)
|| (or)
Greater-than and less-than use only a single
character: > and
-
8/14/2019 Using Formulas to Set Values Based on Values in Multiple Other Fields
2/2
CUMULUS POWER TIP: Using Formulas to Set Values Based on Values in Multiple Other Fields
Canto, the Canto logo and Cumulus are registered trademarks of Canto. Other company and product names might be trademarks of their respective owners. Some productclaims and features are not included in all versions of the software and/or might require additional Cumulus Add-ons or Plug-ins.
Page 2 of 2C|TIP/FormulaMultipleFields/V1.0/08.2009 Copyright 2009 Canto GmbH. All rights reserved. www.canto.com
About Canto & CumulusCanto has been dedicated to helping customers fully utilize their digital assets since 1990.
Canto Cumulus is a cross-platform solution that enables companies to easily organize, find,
share and track their ever-increasing numbers of digital files, in any format. Cantos worldwide
network of certified developers offers an impressive assortment of plug-ins that enhance the
Cumulus product line further.
Learn more: www.canto.com
For more information, contact your
local Canto partner, or Canto:
In the U.S.+1 (415) 495-6545
In the E.U.+49 (0) 30 390 485 0
This statement tests to see if the Approval field is
checked, in which case its considered to have a
value of True.
NOTE: True and false are not case sensitive, so
you can use true, True, false or False. You can
also use 1 for true and 0 for false, if you prefer.
(The entire statement is surrounded by paren-
theses to isolate it from the other code.)
The Boolean connector that follows (&&) indi-
cates that another test follows, and it must also
be true. (|| would be used instead of && if either
of test being true was enough.)
In the code that follows, the various sets of
parentheses are color coded so that its clearer to
you which parentheses are partners. (In com-
puter programming, parentheses always come in
sets of two.)
(fieldValue("Embargo Date")< now())
Lets remove the individual statements from this
line and just see the structure:
(this< that)
Now its easier to see whats happening: This is
less than that. If this is less, then the entire state-
ment becomes true. But if that is less, then the
statement is false.
Now, lets put the original statements back in:
fieldValue("Embargo Date")< now()
First off, now() is a built-in Cumulus function
that returns the current date and time. So, what
were doing in this line is comparing the value in
the Embargo Date field to the current time. If
now() is larger, that means the Embargo Datehas passed.
Finally, we wrap that entire line back into its own
set of parentheses (the red ones) so that
Cumulus can consider it as a whole.
So, now lets look at the entire test portion of
the formula again:
(fieldValue("Approval") == True) &&
(fieldValue("Embargo Date") < now())
Lets read it as Cumulus does:
If Approval is checked and Embargo Date is in
the past, this test is true.
Next comes the part of the formula in which we
tell Cumulus what value we want it to use for
either a true or false test result. We call this the
value portion of the formula. This formulas value
section is very simple.
First you see the question mark. This separates
the test portion of the formula from the value
portion. This is standard for all Cumulus formulas
that include test and value sections.
After the question mark comes the true and false
values that we want Cumulus to put into the
Approved for Distribution field:
? True : False
If our test is true, set Approved for Distribution
to true (check it). If our test is false, setApproved for Distribution to false (uncheck it)
Like all formulas, this one will execute when the
asset is cataloged, and each time thereafter the
asset record is updated.
Do Even More with the Formula.The primary benefit of this document is to show
you how you can test the values of multiple fields
in your formulas. So, if you need to do tests of
three or more fields, just use the same tech-
niques, adding more parentheses where needed.
Examples:
True result in three tests
(Test 1) && (Test 2) && (Test 3)
? True Value : False Value
True result in either of two tests
(Test 1) || (Test 2)
? True Value : False Value
True result in two tests, or true in a third
((Test 1) && (Test 2)) || (Test 3)
? True Value : False Value
Keep in mind, each test used in a formula can
check for values in different fields, or they can
check for value ranges in a single field. (Or combi-
nations thereof.)
Consider the following formula from a Boolean
field called Featured Product. It tests whether
an item is priced between 100 and 200, or
whether the item is on sale. If either of these con-
ditions is true, this test passes and Featured
Product gets a true value.
(
(fieldValue("Price") >= 100)&&
(fieldValue("Price")