How to change values order in multivalue field?(+)

Hi!

  1. Have multivalue text field which is computed. The users want to have two buttons “up” and “down”, and want the values in this field to change their order. Have any ideas?

  2. The users fill this field by selecting docs from another db (PickListCollection) - how to modify this so that selected values were added in the user-specified order?

thnx

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.

Subject: RE: How to change values order in multivalue field?(+)

This blog entry might be helpful: Reordering items in a list