Hey Everyone,
I´m having some trouble with a report in my company and cannot get around to it.
There is one specific model attribute that is supposed to be filled with as many values as needed. It is a glossary of technical terms. I need to output the value of this attribute to a table in the report, and this table should be made of as many rows as the number of technical terms and definitions that were filled in the attribute´s value.
To make sure I made it clear, here is an example:
The Attribute value reads: "term1: definition1; term2: definition2; term3: definition 3;(...);termX: definitionX"
The result in the report should be a table with two columns that looks something like:
Term1: Definition1
Term2: Definition2
Term3: Definition3
(...)
TermX: Definition X.
I hope I could make myself clear. Any help towards achieving that would be greatly appreciated.
Thanks in advance to everyone in the community.
Don't know if you know how to get the Attribut value, I'll just write it here to make sure it's there
var attrValue = modelObj.Attribute(REPLACE_THIS_WITH_THE_ATTR_TYPE_NUM, Context.getSelectedLanguage()).getValue();
Hmm, might be a bit primitive, but I would use the Javascript String.split() function.
See https://www.w3schools.com/jsref/jsref_split.asp to read how exactly it is used.
Basically you will split your string first at each semicolon + space occurrence, and the result of that, before adding it to the return-array, will be split once more at every colon + space occurrence.
function buildArray(stringToBuildWith){ var initialSplit = stringToBuildWith.split("; "); var arrToReturn = []; for each(var singleInitialSplit in initialSplit){ arrToReturn.push(singleInitialSplit.split(": ")); } return arrToReturn; }
With this method (or something similar) you can build yourself a two dimensional array, where elements in the top array represent a term+definition combination, and then the lower level array has two values: the individual term and the individual definition.
You can then create a table, and handle the row creation with a loop through the created 2D array.
p_output.ResetFrameStyle(); p_output.BeginTable(50, [50, 50], Constants.C_BLACK, Constants.C_TRANSPARENT, Constants.FMT_LEFT, 0); for each(var builtArrayElement in buildArray(attrValue)){ p_output.TableRow(); p_output.TableCellF(builtArrayElement[0], 1,1, getString("ID_STYLE_RD_DEFAULT")) p_output.TableCellF(builtArrayElement[1], 1,1, getString("ID_STYLE_RD_DEFAULT")) } p_output.EndTable("", 50, getString("ID_DEFAULT_FONT"), 11, Constants.C_BLACK, Constants.C_TRANSPARENT, 0, Constants.FMT_LEFT, 0);
Of course you can supplement the whole thing with checks whether or not stuff is null, or arrays aren't accessed out of bounds, but I wrote my example plain and simple for the ideal case.
This is great @Kay, thanks for the help.
I was aware that this could be achieved using JavaScript, but I wanted a way of doing that in the WYSIWYG editor, since most of the BPM team does not have programming skills.
Thanks for the solution for now. If anyone else can think of an alternative way of achieving this via the visual editor, it would be greatly appreciated.
The data you want to print is not stored in atomic form (see "database 1NF" for more information), and therefore it is impossible to print it in the way you want it, without splitting it up first. Splitting data is not possible with the WYSIWYG editor.
If you want to rely purely on the WYSIWYG editor I suggest you take the clean approach: ARIS has an object type called "Technical term", which has an attribute called "Name" and an attribute called "Description/Definition" - use multiple of those to store your data in atomic form. Then you can easily use the WYSIWYG editor to ask for object occurrences within the model of the type "Technical Term".