Tip

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 first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
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
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.