Recently, an Acumatica customer of mine needed to print 3-column shipping labels. We scoured the entire application looking for the 3-column labels but never found any. As it turns out Acumatica has 2-column labels but no 3-column labels. It didn’t seem like a daunting task to add one more column to a label print. So, I set on my way to inspect how they did the 2-column version. They say nothing is ever easy. I hope to share my experience creating a 3-column label print in Acumatica.
The key to finding an answer was to study how they (the amazing Acumatica development team) did the 2-column labels and make it into 3-columns. The secret to printing 2-column labels is to set the “Visible Expression” property of the detail band. Using the visible property on the report detail band allows you to conditionally print the entire band. Here the visible property was set to “IndexRow%2”. IndexRow is a report variable that counts the rows printed. Using a modulus function caused it to only print the odd rows (IndexRow %2).
From here they added the 2nd label to the band, then printed the next record by using a Next function. The next function reads the next record from your dataset and prints it. Perfect for printing 2-column labels.
Ok, now how to print one more label. At first, I was thought of using a Next function on a Next function. Seemed logical but didn’t work. Some more research showed me there was a previous function, which as you may have guessed, prints the previous record. Ha, almost tailor made for 3-column labels. Now to modify the “Visible expression” so it printed every 3 records instead of every other. The answer here was to set the detail band visible property to “IndexRow%3=2”. This allowed me to print every 3 records. From here us the previous function to print the record before the current one and the next function to print the record after. The result 3-column labels. YEAAH!!!!!
Not so fast student, there’s an anomaly in this design. When the number of labels is one more than a multiple of 3 you would end up with 1 label on a row. If the entire premise behind my design was to use the previous and next functions of every third row this breaks. I will only be printing 1 label on a row. Now we need some logic to know we have hit this anomaly. We called upon the count function of the Acumatica Report Designer to create a report variable to hold the line count. From here, we can see if there’s only 1 label on a row by using the same modulus function on the line count.
We take the line count mod 3 and when it equals 1, we have hit our condition. We had to modify the detail band visible expression to account for printing a line that’s not a multiple of 3 by adding line count to the expression.
Finally, we use the report designer’s ability to overstrike fields to print one label on a row and use visible expression on each field to control when its printed. When the “OneLabel” property is true we want to print the current label in the first position when its false we are calling the previous function to print the current label.
Phew, indeed true, nothing comes easy. We took the 2-column labels and changed them to 3 ups with a few hacks. The Acumatica report designer is a sophisticated tool disguised as one that easy to use. When you dig deep you find its strength. Now I see why there are no 3-column labels in Acumatica out there.