Quicky Multi-Field Sort

Below is our version of the "quicky" multi-value field sort. The script can be
initiated from a button as below or added to the
edit translation of the field.
Sort List Formula:
Sub Click(Source As Button)
Const CountyNameMacro$ = "@Word(CountyInformation; @Char(126); 1)"
Const CountySeatMacro$ = "@Word(CountyInformation; @Char(126); 2)"
Const CircuitNameMacro$ = "@Word(CountyInformation; @Char(126); 3)"

Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim Item As NotesItem
Set uidoc=ws.CurrentDocument
Set doc=uidoc.Document
Set Item=doc.GetFirstItem("CountyInformation")

REM Sort list alphabetically by county name
uidoc.EditMode = True
SortList = Doc.CountyInformation
NoRecords = Ubound( SortList )
Do
Bubbled = False
For lp = 0 To NoRecords - 1
If SortList( lp ) > SortList( lp + 1 ) Then
temp = SortList( lp )
SortList( lp ) = SortList( lp + 1 )
SortList( lp + 1 ) = temp
Bubbled = True
End If
Next
Loop While Bubbled = True
Doc.CountyInformation = SortList
Doc.CountyNameD = Evaluate(CountyNameMacro$, doc)
Doc.CountySeatD = Evaluate(CountySeatMacro$, doc)
Doc.CircuitNameD = Evaluate(CircuitNameMacro$, doc)
uiDoc.Reload
End Sub

Add Entry Formula:
origList:=@Implode(CountyInformation; "^");

REM "**** Exit if the dialog box is cancelled ****";
@If(@DialogBox("sfCounty"; [AutoHorzFit]:[AutoVertFit]; "Modify County
Information"); ""; @Return(""));
newEntry:=CountyName+"~"+CountySeat+"~"+CircuitName;
@SetField("CountyName"; @DeleteField);
@SetField("CountySeat"; @DeleteField);
@SetField("CircuitName"; @DeleteField);

REM "**** Exit if the entry is already in the list otherwise add to list
****";
@If(@IsMember(newEntry; CountyInformation); @Prompt([OK]; "Duplicate Entry
- Process cancelled"; "This entry is already included in the list.");
@SetField("CountyInformation"; @Explode(@Trim(origList:newEntry);"^")));
@Command([ViewRefreshFields])

Modify Entry Formula:
REM "**** Display a message if the list is empty ****";
@If(@Elements(CountyInformation)=0; @Return(@Prompt([OK]; "County Selection
List Empty"; "There are no items to modify.")); "");

origList:=@Implode(CountyInformation; "^");
displayList:=@Left(CountyInformation; "~");

REM "**** Prompt user for item to modify, exit if cancelled ****";
ItemToEdit:=@Prompt([OKCANCELLIST]:[NoSort]; "Modify entry in List";
"Select an item to modify."; @Subset(displayList; 1); displayList);
@If(ItemToEdit=0; @Return(""); "");

REM "**** Get position of item to edit and obtain the actual list item
value ****";
ItemPosition:=@Member(ItemToEdit; displayList);
ListEntry:=@Trim(@Word(origList; "^";ItemPosition));
@SetField("CountyName"; @Word(ListEntry; "~"; 1));
@SetField("CountySeat"; @Word(ListEntry; "~"; 2));
@SetField("CircuitName"; @Word(ListEntry; "~"; 3));

REM "**** Exit if the dialog box is cancelled else modify ****";
@If(@DialogBox("sfCounty"; [AutoHorzFit]:[AutoVertFit]; "Modify County
Information"); "";
@Do(
@SetField("CountyName"; @DeleteField);
@SetField("CountySeat"; @DeleteField);
@SetField("CircuitName"; @DeleteField);
@Return("")));
newEntry:=CountyName+"~"+CountySeat+"~"+CircuitName;
@SetField("CountyInformation"; @Explode(@Trim(@ReplaceSubstring(origList;
ListEntry; NewEntry));"^"));

REM "**** Remove dialog fields ****";
@SetField("CountyName"; @DeleteField);
@SetField("CountySeat"; @DeleteField);
@SetField("CircuitName"; @DeleteField);
@Command([ViewRefreshFields])

Delete Entry Formula:
REM "**** Display a message if the list is empty ****";
@If(@Elements(CountyInformation)=0; @Return(@Prompt([OK]; "County Selection
List Empty"; "There are no items to delete.")); "");

origList:=@Implode(CountyInformation; "^");
displayList:=@Left(CountyInformation; "~");

REM "**** Prompt user for item to delete ****";
ItemToDelete:=@Prompt([OKCANCELLIST]:[NoSort]; "Delete entry from List";
"Select an item to del
This was last published in November 2000

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close