I am building a history tracker, that continues to work with legacy code in non xpage apps. For xpage apps, I simply call the below function. This works fine:
function AddObjectivesHistoryItem(doc, dt, action, username){
var ArrDocHistory:array = doc.getItemValueArray("History");
if(ArrDocHistory.length < 1){
// This should always return an object as it is created when an objectives
document is first
// created but do this check to be safe and create an array if for some
reason it doesnt exist
ArrDocHistory = [dt+"|"+action+"|"+username];
}else{
// append new value to the array
ArrDocHistory.push(dt+"|"+action+"|"+username);
}
return ArrDocHistory;
}
The issue I have, is splitting and displaying the 3 data types. I have a 3 computed fields, which is date, username and status in a table within a repeat control, code, including first column and computed field below, this should be all values prior to the first pipe delimiter for each multi value.:
<table class="table table-hover">
<thead>
<tr>
<th>Date</th>
<th>Action</th>
<th>Username</th>
</tr>
</thead>
</table>
<table class="table table-hover">
<xp:repeat value="#{document1.History}" var="row">
<tbody>
<tr>
<td>
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[#{javascript:var ArrDocHistory:array = document1.getItemValueArray("History");
print ("LEN: " + ArrDocHistory.length);
var test:array = new Array();
for (i=0; i<ArrDocHistory.length; i++){
var split = ArrDocHistory[i].split("|");
test.push(split[0]);
//return split[i]
}
return test}]]></xp:this.value>
</xp:text></td>
However, what this displays is all the values, in a line, seperated with a comma. For example, "value1, value2, value3" where as I expected, and need, and can't seem to be able to get each value to display on its own, in a new row. For example:
value1
value2
value3
I know I'm doing something silly, but am currently suffering from tunnel vision so any pointers greatly appreciated.
You are returning Test, to a single computed field. Change your repeat to return the array 'test', (it gets the value like you do, than split it to the array you have). Than the computed field returns one of the elements of test.
Put a page break after the computed field to see it the way you want.