Subject: How to change values order in multivalue field?(+)
Hi Aleksey,
I take it that the list you are referring to is a list box field. For the sake of my example lets call this field “ListBox”. Lets call the field that you are getting your list elements from “ListEntries”. You need to code a routine to move the selected list element up or down one position. Here is the code for doing that.
Sub MoveListElement(direction as String)
Dim Values as Variant
Dim SelectedValue as String
Dim ws as New NotesUiWorkspace
Dim Doc as NotesDocument
Dim x as Integer
Dim Target as Integer
Dim Temp as String
Set Doc = ws.CurrentDocument.Document
’ Get the value list and selected value
Values = Doc.GetItemValue(“ListEntries”)
SelectedValue = Doc.GetItemValue(“ListBox”)(0)
’ Find ordinal position on selected value in the list
Target = -1
For x = 0 to UBound(Values)
If Values(x) = SelectedValue Then
Target = x
End If
Next
’ Check for impossible operations
If direction = “UP” and Target = 0 Then
MsgBox “Item is already at the top you dumbass”
Exit Sub
End If
If direction = “Down” and Target = UBound(Values) Then
MsgBox “Item is already at the bottom you dumbass”
Exit Sub
End If
’ Reposition the list item
If direction = “UP” Then
Temp = Values(Target-1)
Values(Target-1) = Values(Target)
Values(Target) = Temp
Else
Temp = Values(Target+1)
Values(Target+1) = Values(Target)
Values(Target) = Temp
End If
Doc.ReplaceItemValue “ListEntries”, Values
ws.CurrentDocument.Refresh
End Sub
Simply call this routine from the buttons passing the direction as a string. Youmay have to mess around with the refreshing a bit to get the control to update itself but this should give you the basic idea to get you started.