2019.1

Table Of Contents
Zeppelin 3 and Led Zeppelin 4 albums inside the same record, even though they were
released in different years.
Essentially, we need to combine both these conditions and set the record boundary when
EITHER the year OR the artist changes.
Here's what the script would look like:
/* Read the values of both columns we want to check */
var zeBand = boundaries.get(region.createRegion("Artist"));
var zeYear = boundaries.get(region.createRegion("Released"));
/* Check that at least one of our variables holding previous values
has been initialized already, before attempting to compare the
values */
if (boundaries.getVariable("lastBand")!=null) {
if (zeBand[0] != boundaries.getVariable("lastBand") || zeYear[0]
!= boundaries.getVariable("lastYear") )
{
boundaries.set();
}
}
boundaries.setVariable("lastBand",zeBand[0]);
boundaries.setVariable("lastYear",zeYear[0]);
l The script first reads the two values from the input data, using the createRegion() method
(see: "Example" on page413). For a CSV/database data type, the parameter it expects is
simply the column name. The region is passed as a parameter to the get() method, which
reads its contents and converts it into an array of strings (because any region, even a
CSV field, may contain several lines).
l To "remember" the values that were processed the last time the event was triggered, we
use variables that remain available in between events. Note that these variables are
specific to the Boundary context and not available in any other scripting context in the
DataMapper.
l The script first checks if those values were initialized. If they weren't, it means this is the
first iteration so there's no need to compare the current values with previous values since
there have been none yet. But if they have already been initialized, then a condition
checks if either field has changed since last time. If that's the case, then a boundary is
created through the set() method.
Page 386