Highlight duplicates in a table

kclark
kclark E
edited February 11, 2022 in Analytics #1
Example showing how to highlight duplicate data in a table using a highlight rule and an ArrayList.<br />
<br />
I create an ArrayList in the beforeOpen of my data set.
array = new java.util.ArrayList();
<br />
Then I had to store the values of the column I wanted to check for later in the onFetch()
array.add(row&#91;"QUANTITYORDERED"]);
<br />
I also had to store this ArrayList as a global persistent variable from afterClose()
reportContext.setPersistentGlobalVariable("array", array);
<br />
Now that all the values are stored I can use the following scripts as expressions from the highlight rule UI.
var array = reportContext.getPersistentGlobalVariable("array");
var first   = array.indexOf(row&#91;"QUANTITYORDERED"]);
first;
<br />
Not Equal to
var array = reportContext.getPersistentGlobalVariable("array");
var last   = array.lastIndexOf(row&#91;"QUANTITYORDERED"]);
last;
<br />
highligh_duplicates.png
Warning No formatter is installed for the format ipb