?
Solved

How to Create a Pop Up Box for a field with Search Capabilities

Posted on 2009-02-24
18
Medium Priority
?
443 Views
Last Modified: 2013-12-18
I have a few databases that have DB column lookups to populate drop down lists.  The only way users can get down the list faster is to type the first letter.  For instance, if they type C it goes to the C's.  Well, if they type the second letters, say O, it flips to the O's when what they needed was CO.

So, I have a few questions.  Is there a way for it to look for CO in the dropdown or COR instead of C...then to Os..then to Rs?  If not, can I have a searchable dialogue list field pop up?  As in, there are 2000 products and I want the one that starts with COR?  When dealing with huge 2000+ lists, it would just make it easier.

I code in mostly Lotus Script...so, if possible, the solution needs to be something I can do in Lotus Script.

Thanks for any help in advance.
0
Comment
Question by:onederwomyn
  • 7
  • 5
  • 3
  • +2
18 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 23724502
Not sure. but I would separate the search from the drop down list
have a search box above the drop down list, so typing cor and Return, only brings up cor in the drop down list.

 
I hope this helps !
0
 
LVL 22

Assisted Solution

by:mbonaci
mbonaci earned 450 total points
ID: 23725039
I happen to have the code that does the following:

I have multiple fields on one form that need to be filled with values from one, previously chosen document.

It goes like this:
User clicks on the button besides the lookup field and then, after the code gets the value from the field, if the value is empty string you get prompted with all documents in the view, but if you have entered first few letters you get prompted with the list with only those values that start with entered sequence of letters.

The attached file is nsf with subform that is used as the dialog box in the code (rename the file extension after downloading).

It's maybe a little complicated on first glance, but study it a little bit and it'll work like a charm.
Ask if you get stuck...


Mb¤
Sub Click(Source As Button)
	'Mb¤, 23.09.2005.
	On Error Goto errHandler
	Dim w As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim v As NotesView
	Dim c As NotesDocumentCollection
	Dim cur As NotesDocument
	Dim uidoc As NotesUIDocument
	Dim cnt As Integer
	Dim prekName As String
	
	Set uidoc = w.CurrentDocument
	Set db = uidoc.Document.ParentDatabase
	Set v = db.GetView( "va_LookupPreks" )
	prekName = uidoc.FieldGetText( "strPrekName" )
	
	If prekName = "" Then		'If user clicked refresh and the field is empty - give him the whole view to choose from
		Set cur = promptForPrekRetrieval( uidoc )
	Else
		Set c = v.GetAllDocumentsByKey( prekName, False )		'non exact-match lookup
		If c Is Nothing Then Exit Sub
		cnt = c.Count
		If cnt = 0 Then Exit Sub
		
		If cnt = 1 Then
			Set cur = c.GetFirstDocument
		Else
			'Array with field names we want displayed for each Prek in dialog box
			Dim tmpArr(4) As String
			tmpArr(0) = "strPrekName"
			tmpArr(1) = "strZ"
			tmpArr(2) = "strC"
			tmpArr(3) = "strS"
			tmpArr(4) = "strT"
			
			Set cur = promptToSelectDoc( c, "strPrekName", tmpArr, "sa_dlgDocumentsList" )
		End If
	End If
	
	If cur Is Nothing Then Exit Sub
	
	'fill uidoc fields with selected Prek
	Call uidoc.FieldSetText( "strPrekName", cur.strPrekName(0) )
	Call uidoc.FieldSetText( "strZ", cur.strZed(0) )
	Call uidoc.FieldSetText( "strC", cur.strCian(0) )
	Call uidoc.FieldSetText( "strS", cur.strSlow(0) )
	Call uidoc.FieldSetText( "strT", cur.strTrebble(0) )
	
	Call uidoc.GotoField( "strPrekName" )
	
leave:
	Exit Sub
ErrHandler:
	'Call ErrorMsg( E_ERR, "Subform sa_dlgPrekrsaj: Refresh button", Erl, Err )	'Create your error handler
	Resume leave
End Sub
 
 
 
 
Function promptForPrekRetrieval( uidoc As NotesUIDocument ) As NotesDocument
	'Mb¤, 21.09.2005.
	'Function returns selected document (just one) from "prek" registry view
	On Error Goto ErrHandler
	Dim w As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim c As NotesDocumentCollection
	
	Set db = uidoc.Document.ParentDatabase
	
	Set c = w.PickListCollection( 3, False, db.Server, db.FilePath, "va_Preks", "Choose prek", "Choose one prek from the list:" )
	If c Is Nothing Then Exit Function		'Just in case
	If c.Count = 0 Then Exit Function		'This is Cancel
	
	'Here we are sure that one doc was choosen
	Set promptForPrekRetrieval = c.GetFirstDocument
	
leave:
	Exit Function
ErrHandler:
	'Call ErrorMsg( E_ERR, "Subform sa_dlgPrekrsaj: Function: promptForPrekRetrieval", Erl, Err )	'Create your error handler
	Resume leave
End Function
 
 
 
 
 
Function promptToSelectDoc( c As NotesDocumentCollection, SortField As String, FieldNames() As String, DialogType As String ) As NotesDocument
	'Mb¤, 08.09.2005
	'Function raises dialog with received collection - "c"
	'Documents are represented in dialog with values of the fields listed in "FieldNames" param array
	'Documents are sorted in dialog by value of the field "SortField" (if SortField is an empty string we don't sort the collection)
	'Subform (or form) name that is shown in the dialog is the last function argument - "DialogType"
	'It's NOT multi-value selection list
	On Error Goto ErrHandler
	Dim s As New NotesSession
	Dim w As New NotesUIWorkspace
	Dim db As NotesDatabase
	Dim tmpDoc As NotesDocument, cur As NotesDocument
	Dim tmpArray() As String, tmpList List As String
	Dim i As Integer, j As Integer
	Dim flag As Variant, unid As String
	
	Set db = s.CurrentDatabase
	Set tmpDoc = db.CreateDocument
	Redim tmpArray( c.Count - 1 )
	
	If SortField <> "" Then
		Set c = SortCollection( c, SortField )
	End If
	
	For i = 1 To c.Count
		Set cur = c.GetNthDocument( i )
		unid = cur.UniversalID
		For j = 0 To Ubound( FieldNames )
			tmpList( unid ) = tmpList( unid ) + cur.GetItemValue( FieldNames( j ) )(0) + " - "
		Next
		tmpList( unid ) = Left( tmpList( unid ), Len( tmpList( unid ) ) - 3 )		'Cut minus sign and spaces from the line end
	Next
	
	'transfer list values into array to be able to show them in the field
	i = 0
	Forall el In tmpList
		tmpArray( i ) = el
		i = i + 1
	End Forall
	tmpDoc.Lista = tmpArray 	'transfer array into the dialog field
	
	flag = w.DialogBox( DialogType, True, True, False, False, False, False, "Documents", tmpDoc )
	If Not flag Then Exit Function 		'This is Cancel
	
	Forall el In tmpList
		If el = tmpdoc.strPreks(0) Then							'if I'm the one selected
			Set promptToSelectDoc = db.GetDocumentByUNID( Listtag( el ) )		'locate me by my UNID stored earlier as the list tag
			Exit Forall
		End If
	End Forall
	
leave:
	Exit Function
ErrHandler:
	'Call ErrorMsg( E_ERR, "libStandard: Function: promptToSelectDoc", Erl, Err )	'Implement your own error handling
	Resume leave
End Function
 
 
 
 
Function sortCollection( collection As NotesDocumentCollection, Key As String ) As NotesDocumentCollection
	'Mb¤, 23.09.2005.
	'Function sorts received collection by values in the field <Key> using ShellSort algorithm and returns the new, sorted collection
	On Error Goto Errhandler
	Dim session As New NotesSession
	Dim db As NotesDatabase
	Dim doc() As NotesDocument, doc1 As NotesDocument, doc2 As NotesDocument
	Dim tmpdoc As NotesDocument, tempdoc As NotesDocument
	Dim key1 As Variant, key2 As Variant
	Dim h As Integer, index As Integer, i As Integer, j As Integer
	Dim TestValue As String, Value As String, tmpID As String
	Dim collection2 As NotesDocumentCollection
	
	Set db = session.CurrentDatabase
	
	Redim doc( collection.Count - 1 ) As NotesDocument
	i = 1
	Set doc1 = collection.GetFirstdocument
	While Not doc1 Is Nothing
		Set doc2 = collection.GetNextDocument( doc1 )
		Set doc( i - 1 ) = doc1
		i = i +1
		Set doc1 = doc2
	Wend
	
	'Sort all documents by field "Key":
	If Not ( doc(0) Is Nothing ) Then
		h = 1	
		Do While h < Ubound( doc ) +1
			h = 3 * h + 1	
		Loop
		h = ( h - 1 ) / 3
		If h > 3 Then
			h = ( h - 1 ) / 3
		End If
		
		Do While h > 0
			For  index = ( h + 1 ) To Ubound( doc ) + 1
				TestValue = doc( index - 1 ).GetItemValue( Key )(0)
				j = index - h
				Do While j > 0
					Value = doc( j - 1 ).GetItemValue( Key )(0)
					If Value > TestValue Then		'Change
						Set tempdoc = doc( j + h - 1 )
						Set doc( j + h - 1 ) = doc( j - 1 )
						Set doc( j - 1 ) = tempdoc
					Else
						Exit Do
					End If
					j = j - h
				Loop
			Next index
			h = ( h - 1 ) / 3
		Loop		
	End If
	
	'This is the trick that ensures we get an empty collection without causing any errors:
	Set tmpdoc = db.GetProfileDocument( "SortCollectionDummyDoc" )
	tmpID = tmpDoc.NoteID
	Set collection2 = tmpdoc.Responses
	
	'Transfer previously sorted array with documents to collection:
	For index = 0 To Ubound( doc )
		Call collection2.AddDocument( doc( index ) )
	Next
	
	Set SortCollection = collection2
	
leave:
	Exit Function
ErrHandler:
	'Call ErrorMsg( E_ERR, "libStandard: Function: SortCollection", Erl, Err )	'Implement your own error handling function
	Resume leave
End Function

Open in new window

Choose.gif
0
 

Author Comment

by:onederwomyn
ID: 23725205
Wow...yeah, I will be honest.  That looks intimidating!
It would be nice wouldn't it, though, if IBM would just include that type of things as a field type?  I mean, it has multi-letter lookup for email addresses, why not have it for non address fields?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:onederwomyn
ID: 23725582
Whoops... I meant I do most of my stuff in formula language.

I am pretty sure I can use @Picklist, but I have never used it before.  What initiates the @Picklist?  I assume I have to create a new button.  Then, if the field is product...would the code for the button look like this:
product:=@Picklist (yadda, yadda, yadda...I know what goes in these fields)

?
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 23731548
It's just a matter of pasting the code in few places... without LotusScript you're going nowhere with this...
0
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 450 total points
ID: 23731634
No, Notes doesn't have that feature of typing COR etc.

For a makeshift solution, much depends on the requirements. Suppose that the following were allowed, assuming we're working from a form:
- an additional field where the user can type COR
- he has to type the F9-key (or click a button to refresh)
- a hidden multi-value field on the form is populated with the matching products
- the dialog list that gets its options from that field (Refresh choices on document refresh)

I think it can be done with only a few lines or formula code.

Eh, hi Marko, once again we don't quite agree :-))
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 23731678
Yea, yea, I'll have to agree with you...
I've had a few more checks so it had to be done in LS...
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23731741
LOL !
0
 

Author Comment

by:onederwomyn
ID: 23733160
So, put in a search box and then have a dialog list actually be the field that has the values that say @contain "COR" in DBColumn?  Did that make sense?  Hehe.  It is too early in the morning.  I have always just pulled up direct database columns, never filtered them.  Can you use @contains with a column lookup?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23733464
Tumting like this, assuming your text-field is called StartsWith:

sw:= @LowerCase(StartsWith);
all:= Lowercase(@DbColumn(....));
sel:= sw+@Trim(@Right(all; sw))

The formula above is not entirely correct, for if you type the complete name of a product, it will not be displayed. But try first if this works so far. I'll think about the improvement in the meantime.
0
 

Author Comment

by:onederwomyn
ID: 23733544
Ahh -- I see where you are going.  I am actually not coding this piece until the weekend, but I wanted to be full steam ahead when I get there...

Thanks for your help thus far, it is definitely appreciated!!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23733606
We'll stay tuned!
0
 

Author Comment

by:onederwomyn
ID: 23733612
What about using @SetViewInfo ?  Do you actually have pull up the view, or can you set a view as part of the dialogue box field?  Hmmm...now I am intrigued.  I mean that function does filter by a prompt.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 23733815
It only works on the current, open view... Furthermore, you'd have to add a column for each number of letters you want to search on (so A, AA, AAA etc.).

I don't know, but I suppose it just might be possible in a @PickList, if you add the @ViewInfo to the PostOpen event of the view opened in the @PickList (which is a hidden view, of course). Seems like a very tricky solution...
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 600 total points
ID: 23751833
Actually, Notes does have the ability to type more than the first charca in the list, I think that was introduced with R7. I don't think it works for drop down lists, but it does work for dialog lists and list boxes.
0
 

Author Comment

by:onederwomyn
ID: 23751878
Really?  Because I made a dialog box in 8 and I would type a C, it would go to Cs...then I type an O and it goes to O, instead of going to CO.  I am pretty sure. I guess I will have to double check.  But, hell if list boxes work, that would be fine.  Thanks!
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 23752084
Also, you may need to type fast ....

0
 

Author Comment

by:onederwomyn
ID: 23857068
Ok folks...dialogue list and list boxes don't work.  What does work, however (I played around), is if I choose field type NAME and have it list from a column in a view.  When the box pops us...if you start typing the beginning a search box appears.  It works pretty good.  Thanks for everyone's help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month16 days, 5 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question