There are times when report requirements can put a report writer in a box. For example, a recent request came in with the following requirements:
- Portrait orientation
- No text wrapping
- Include workorder.wonum, workorder.description, workorder.worktype, workorder.status, workorder.statusdate, sum(wplabor.regularhrs)
Oops. No text wrapping and the Description field needs to be included?1 Typically this is where a report writer has to decide on how to deal with wordy work order descriptions. An example of a common task that food industries have to do on a regular basis is sanitize tools that are used in food production areas. So an expected work order description could be:
WEEKLY TOOL SANITATION FOR MILK RECEIVING AND PASTEURIZED PRODUCTS BAYS
This description happens to be 'just' 71 characters long. Initial testing of the report showed that the workorder.description field would be too much if it was left at full length. A common way to trim a text string would be to just show 'x' number of characters starting from the left, like this:
BirtStr.left(row["description"], 35)
This results in the following work order description:
WEEKLY TOOL SANITATION FOR MILK RE
While that works, leaving the workorder.description field to stop suddenly can raise questions by the recipient of the report:
- Did the report not get formatted correctly?
- Is there an issue with the Maximo data?
- Did someone do a sloppy job entering the work order?
Not the thoughts you want running through a Plant Manager, a Maintenance Manager, or worse. A common phrase you hear in programming is making sure a program exits gracefully. Instead of just trimming the field, here's an easy method to make sure a long text field ends gracefully. Instead of including BirtStr.left(row["description"], 35)
in a Dynamic Text element, use the following code:2
if (BirtStr.charLength(row["description"]) > 35) {
BirtStr.left(row["description"], 33) + '...'
}
else {
row["description"]
}
The If-Else
statement will take a look at and the length of the field, and if it exceeds 35 characters, it will trim it back to 33 characters and then append it with '...'. Now when the workorder.description field is printed on the report it will show up as:
WEEKLY TOOL SANITATION FOR MILK ...
This better indicates to the recipient that while not all the text is present, Maximo should have additional details if needed.