Domino Code Fragment

Code Name*
Moving an item within a list
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.221.222.47
Description*
Moves an Item up or down in a list
Type*
Formula
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
This has the same effect of File->Tools->User Preferences->Ports Dialog box of moving port name up and down.
Files/Graphics attachments (if applicable): Code:
Create a form with a layout region.
1. Create a field "Fld1". Assign keyword data type and computed and type "Fld2" in "Formula

   for Choices". Check both the property of "Refresh on keyword change" and "Refresh choices
   on document refresh".
2. Create a field "Fld2" and assign text datatype and editable. Check multi-value property.

   Hide the field for both read and write mode.
3. Create a graphic button for moving the items up and enter the following formula.


tmp:=fld1;
max:=@Elements(fld2);
tmp1:=@Member(tmp;fld2);
tmp2:="";
tmp3:="";
tmp4:="";
tmp5:="";
@If((tmp1-2) > 0 ; @Set("tmp2";@Subset(fld2;(tmp1-2)));@Set("tmp2";""));
@If((tmp1-1) > 0 ; @Set("tmp3";@Subset(@Subset(fld2;(tmp1-1));-1));@Set("tmp3";""));
@If(tmp1 > 0 ; @Set("tmp4";@Subset(@Subset(fld2;(tmp1));-1));@Set("tmp4";""));
@If((max-tmp1) > 0 ; @Set("tmp5";@Subset(fld2;(tmp1-max)));@Set("tmp5";""));
FIELD fld2 := tmp2:tmp4:tmp3:tmp5;
FIELD fld1 := tmp;
@Command([ViewRefreshFields])


4. Create one more graphic button for moving down the items in the list.

tmp:=fld1;
max:=@Elements(fld2);
tmp1:=@Member(tmp;fld2);
tmp2:="";
tmp3:="";
tmp4:="";
tmp5:="";
@If((tmp1-1) > 0 ; @Set("tmp2";@Subset(fld2;(tmp1-1)));@Set("tmp2";""));
@If((tmp1) > 0 ; @Set("tmp3";@Subset(@Subset(fld2;(tmp1));-1));@Set("tmp3";""));
@If(tmp1+1 > 0 ; @Set("tmp4";@Subset(@Subset(fld2;(tmp1+1));-1));@Set("tmp4";""));
@If((max-(tmp1+1)) > 0 ; @Set("tmp5";@Subset(fld2;((tmp1+1)-max)));@Set("tmp5";""));
FIELD fld2 := @Unique(tmp2:tmp4:tmp3:tmp5);
FIELD fld1 := tmp;
@Command([ViewRefreshFields])


5. Press F9 to refresh the fields or type @command([ViewRefreshFields]) in the document
postopen event.