Is there any easy (or not-so-easy) way to display the values of a multiple value field in reverse order? We have a field that gets a value appended to it each time the document is saved. The users want to have the values display (in a computed for display field) in the opposite order, so that the most recent addition is at the top. @Sort doesn’t work, since the values are not in alphabetical or numerical order to begin with.
Subject: Reversing order in multivalue fields
only because i am more of a script person, I would do the comp for display off of itself, and then in the query open, load the field going from the last element to the first step -1.
john
Subject: RE: Reversing order in multivalue fields
Hi There,
You are likely computing the value with something like this:
CurVal := YourField;
NewVal := TempField;
@SetField(“YourField”;CurVal:NewVal)
Try this instead
@SetField(“YourField”;NewVal:CurVal)
HTH
Mark
Subject: RE: Reversing order in multivalue fields
Nope, the values are appended during a big honkin’ chunk of LS code in the querysave. No formula; just AppendToTextList.
Subject: Reversing order in multivalue fields
Here is code that will reverse the list:
count := @Elements(fieldname);
@For(n := count;n > 0; n := n-1;
disp := disp : fieldname[n]);
@Trim(disp)
You might want to run an agent that updates all of the documents, then change your code to put new values on top of the list instead of the bottom as Mark Landry suggested.
Subject: RE: Reversing order in multivalue fields
Thanks for the code; that’s what I needed. No to the second suggestion, though - there are times when we need the data in the order it’s stored. It’s only for display on one form that it needs to be seen in reverse order.
Subject: Reversing order in multivalue fields
this works too:
n := @Elements(items);
newlist := newlist;
@While(n != 0;
@Set(“nextword”; @Word(@Implode(items; “;”); “;”; n));
@Set(“newlist”; @Explode(newlist : nextword; “;”));
n := n - 1);
@Explode(newlist; “;”)
items = your field name on form that contains the values you want to reverse.
Subject: RE: Reversing order in multivalue fields
I used this code below in the field called “test” to reverse the UpdDate field.
oldlist := UpdDate;
@For(i := 1;i <= @Elements(oldlist) ; i := i + 1; newList := oldlist[i]:newlist);
newlist
It works, but you need to edit the document and then refresh the document to show the last entry. It gives me an error if I try to edit (@command) and refresh. I also tried calling an agent, but that didn’t work either.
Any thoughts?
Michele
Subject: Reversing order in multivalue fields
try this (input is the input field name and output is the reversed order field list
e := @Elements(input);
u := input;
i := 1;
@For(n := e; n >= 1; n := n - 1;
o := o + @If(o = “”; “”; “~”) + u[n];
i := i + 1);
@Explode(o;“~”)
HTH
Don