Advertisement

05.02.2008 at 10:44AM PDT, ID: 23372411
[x]
Attachment Details

Dblookup for # in View document

Asked by xcomapoc in Lotus Domino Email Server

Tags: IBM, Lotus Notes 8, Non web

Need some help with populating a Checkbox field using dblookup. I want the Checkbox field to contain a field from the first document. Another checkbox field to contain a field from the 2nd document, etc . I have used dblookup before, but I have never seen this done.  Example. I have 10 documents. I want to create another document with 10 checkboxes where each checkbox holds the subject of each document.  Checkbox field #1 contains the subject of document 1 in the view. Checkbox field#2 contains the subject of document 2 in the view. Start Free Trial
 
Keywords: Dblookup for # in View document
 
Loading Advertisement...
 
[+][-]05.02.2008 at 11:14AM PDT, ID: 21488802

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 11:40AM PDT, ID: 21489033

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 12:00PM PDT, ID: 21489186

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 01:38PM PDT, ID: 21489899

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.02.2008 at 01:43PM PDT, ID: 21489914

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 06:24AM PDT, ID: 21499804

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Lotus Domino Email Server
Tags: IBM, Lotus Notes 8, Non web
Sign Up Now!
Solution Provided By: Bill-Hanson
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.06.2008 at 06:22AM PDT, ID: 21507028

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 07:41AM PDT, ID: 21507656

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 08:54AM PDT, ID: 21508385

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 10:01AM PDT, ID: 21509015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 10:31AM PDT, ID: 21509270

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 11:20AM PDT, ID: 21509625

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 01:39PM PDT, ID: 21510844

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
05.02.2008 at 11:14AM PDT, ID: 21488802
You'll need to use LotusScript and the NotesViewNavigator class to get this done.

It would help to know your view name and field names, but here's a simple example showing how this is done.

This code should be placed in your form's PostOpen module.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim nav As NotesViewNavigator
	Dim entry As NotesViewEntry
	Dim doc As NotesDocument
	Dim count As Integer
	Set doc = Source.Document
	Set db = doc.ParentDatabase
	Set view = db.GetView("VIEW_NAME")
	Set nav = view.CreateViewNav
	Set entry = nav.GetFirstDocument
	Do While (Not entry Is Nothing)
		count = count + 1
		Call doc.ReplaceItemValue("FIELD_" & count & "_CHOCIES", entry.Document.GetItemValue("CHOICE_VALUE")(0))
		Set entry = nav.GetNextDocument(entry)
	Loop
Open in New Window
 
05.02.2008 at 11:40AM PDT, ID: 21489033
Thanks for the quick reply.
The main doc field in the view is Subject.

The ten checkboxes are
SubmissionList:
SubmissionList_1:
SubmissionList_2:
SubmissionList_3:
SubmissionList_4:
SubmissionList_5:
SubmissionList_6:
SubmissionList_7:
SubmissionList_8:
SubmissionList_9:
 
05.02.2008 at 12:00PM PDT, ID: 21489186
How did the code work out?
 
05.02.2008 at 01:38PM PDT, ID: 21489899
What should this line look like?
 Call doc.ReplaceItemValue("FIELD_" & count & "_CHOCIES", entry.Document.GetItemValue("CHOICE_VALUE")(0))
 
05.02.2008 at 01:43PM PDT, ID: 21489914
It's not working. I have the following.
Set view = db.GetView("topten")
      Set nav = view.CreateViewNav
      Set entry = nav.GetFirstDocument
      Do While (Not entry Is Nothing)
            count = count + 1
            Call doc.ReplaceItemValue("SubmissionList_" & count & "_CHOCIES", entry.Document.GetItemValue("Subject")(0))
            Set entry = nav.GetNextDocument(entry)
 
05.05.2008 at 06:24AM PDT, ID: 21499804
Did you remember to set the choice formula for each checkbox to one of the new 'choice' items?  For example, the choice formula for the 'SubmissionList' field should be SubmissionList_0_CHOCIES.

You can make things easier on yourself if you choose a standard naming convention for your checkbox fields.  For example, if they were named SubmissionList_0, SubmissionList_1, ..., SubmissionList_N, then we would not have to modify the code that sets the choice values.  But since the names are not conventional, we should take that into account so that our choice formulas become simpler.

If you use the code below, then you can use the same choice formula for all of your checkbox fields:

@ThisName + "_Choices"
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
	Set view = db.GetView("topten")
	Set nav = view.CreateViewNav
	Set entry = nav.GetFirstDocument
	Do While (Not entry Is Nothing)
		If (count = 0) Then
			Call doc.ReplaceItemValue("SubmissionList_Choices", entry.Document.GetItemValue("Subject")(0))
		Else
			Call doc.ReplaceItemValue("SubmissionList_" & count & "_Choices", entry.Document.GetItemValue("Subject")(0))
		End If
		count = count + 1
		Set entry = nav.GetNextDocument(entry)
	Loop
Open in New Window
Accepted Solution
 
05.06.2008 at 06:22AM PDT, ID: 21507028
Only changed the first 3 checkboxes to see what happens. No Go. See attached pic.
 
screen print of results
screen print of results
 
 
05.06.2008 at 07:41AM PDT, ID: 21507656
It looks like you still have the checkboxes setup to use text for the choices instead of a formula.  Here's how the checkbox fields should be setup:

- On the checkbox's 'Control' tab (2nd tab), change 'Enter choices (one per line)' to 'Use formula for choices'.

- In the 'Choices' property, you should have the name of the field that contains the choice(s) for that field.  This is considered a formula because Notes needs to evaluate the choice value(s) at run time.

- Enable the 'Refresh choices on document refresh' setting.

That should do it.
 
05.06.2008 at 08:54AM PDT, ID: 21508385
This is getting confusing. I had the checkbox set for formula. In the first instance you say set the formula to  @ThisName + "_Choices" which gave the results in the picture.Setting it to the field name of the value, I'm guessing, Subject, now I get checkboxes without any text. Just the boxes.
 
05.06.2008 at 10:01AM PDT, ID: 21509015
OK.  I see what's happening.

The formula I gave you (@ThisName + "_Choices") is bogus.  It only computes the name of the field that contains the choice values.  That is why the checkboxes displayed the field names rather than their values.

What I said in my last post is still technically correct, though.  If you put the name of the field in the choices formula, it will work.  For example, for the first checkbox, the formula would be "SubmissionList_Choices" (no quotes).  This is OK, but you would have to enter the name of each choice field in each checkbox.

The formula from the previous post computes the choice field name automatically, but I forgot one step.  We don't want the name of the field, we want the values contained in the field, so the formula for each checkbox really should be

    @GetField(@ThisName + "_Choices")
 
05.06.2008 at 10:31AM PDT, ID: 21509270
But the names of the fields don't have _Choices appended to them. where is this coming from?
 
05.06.2008 at 11:20AM PDT, ID: 21509625
Those are the backend-only fields that are created by the PostOpen code.  They don't appear on the form.  We create them behind the scenes then use their values for the checkboxes.

Here's the part of the code that creates / updates the values in the "Choice" fields...

        Do While (Not entry Is Nothing)
                If (count = 0) Then
                        Call doc.ReplaceItemValue("SubmissionList_Choices", entry.Document.GetItemValue("Subject")(0))
                Else
                        Call doc.ReplaceItemValue("SubmissionList_" & count & "_Choices", entry.Document.GetItemValue("Subject")(0))
                End If
                count = count + 1
                Set entry = nav.GetNextDocument(entry)
        Loop

... Then, in the checkbox choices formula, we use the values as selection choices...

        @GetField(@ThisName + "_Choices")

Basically, since @DbLookup can't do what we need efficiently enough, we use LotusScript when the form is opened to do the lookups and store the values in hidden fields in the current document.  Then, we just use the values in the hidden fields for our checkbox choices.

If the values don't change often, you can speed up this code even more by periodically caching the lookup values in a profile document.
 
05.06.2008 at 01:39PM PDT, ID: 21510844
I've hidden the Choices fileds in the doc and the results are good. The checkbox fields are not populated until the doc is saved. Is  there some script code I can insert to refresh the doc or do I have to save it first? Rather not save right from the start.
 
 
05.07.2008 at 07:21AM PDT, ID: 21516652
OK, now that we have things working (sort of), we need to talk about form events and timing for just a bit.  So far, we have some LotusScript code that will load choices into a set of hidden fields and some @Formula code that makes the values in the hidden fields available to the checkboxes.  Now, we need to ...

1) Make sure that the form shows the choices as soon as it loads.

2) Get rid of the temporary choice fields once we're done with them (no need to waste storage space by keeping them in the document).

3) Make sure that the form displays the current choices even when the form is in read-mode.

#1 is easy.  First, make sure that all of your checkbox fields have the "Refresh choices on document refresh" property enabled.  Then, just refresh the form at the end of the PostOpen event.  Here's the line that you need to add:

    If (Source.EditMode) Then Call Source.Refresh

#2 is also easy.  You can handle this 2 different ways:

#2a - Use Computed For Display fields for the choice fields (recommended).  If you add the choice fields to the form (it sounds like you already did), then you can set them up so that the choice values never get saved to the database.  To do this, change the field type to "Computed for display", enable "Allow multiple values", and put the choice field name in the choice field's "Value" property.  For example, if you are setting up the "SubmissionList_Choices" field, then the value should be "SubmissionList_Choices" (no quotes).  That's it.  Notes will not allow the values to be saved to the backend document.  Note:  If you have existing records in the database that already have the choice values saved in the document, this will not remove them.  It only prevents the values from entering new documents.

#2b - Remove the temp fields in the form's QueryClose event.  You would have to remove the fields from the document using LotusScript, then perform a second save on the backend document.  Try using #2a first.  If you want to explore this option, just let me know.

#3 is also pretty simple, but you need to understand a few things about form events and timing.

There are two events that we can code to manipulate the document as the form opens: QueryOpen and PostOpen.  As the names imply, QueryOpen runs before the form is displayed and PostOpen runs just after it is displayed.

I choose QueryOpen in the example above because it is the easiest to understand, and I wanted to keep things simple until you had the core functionality up and running.  Now, you need to understand the differences between the two events.

There are 3 main issues that we need to be aware of:

1) When you compose a new document, Source.Document is Nothing in QueryOpen because the backend document has not been created yet.  This is why I did not have you put the code into this event to start with.  When you open an existing document, however, the backend document is available.

2) The UI form is never available in QueryOpen since the form is not displayed yet.

3) Once the form has loaded, you can't call NotesUIDocument.Refresh if the form is in read-mode (which we now do in PostOpen per #1 above).

So, it sounds like we have a catch-22 situation.  We can't load the choices in QueryOpen for new docs because there's no document available, and we can't load them in PostOpen for existing documents because we can't refresh the form in read-mode.

The trick is to put the code in both events!  Also, since we don't want two sets of identical code (for maintenance and performance reasons), we should move your code into a reusable function (Am I pushing your LotusScript limits yet?  Good!).

I've included an example of the function definition below.  Just paste this code into the "Declarations" module of your form (if you've changed the code, you'll need to apply the changes here as well).  Note that the call to Source.Refresh has been left out on purpose.

Now remove the old code from PostOpen and make your QueryOpen and PostOpen events look like this:
      

      Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
            
            If (Not Source.IsNewDoc) Then Call LoadCheckboxChoices(Source)
            
      End Sub


      Sub Postopen(Source As Notesuidocument)
            
            If (Source.IsNewDoc) Then Call LoadCheckboxChoices(Source)
            If (Source.EditMode) Then Call Source.Refresh
            
      End Sub


Now, QueryOpen loads the choices for existing documents and PostOpen loads the choices for new docs.

Sorry for the long-winded response, but I didn't want to leave you hanging without finishing this up the right way.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Sub LoadCheckboxChoices(Source As NotesUIDocument)
	
	Dim db As NotesDatabase
	Dim view As NotesView
	Dim nav As NotesViewNavigator
	Dim entry As NotesViewEntry
	Dim doc As NotesDocument
	Dim count As Integer
	Set doc = Source.Document
	Set db = doc.ParentDatabase
	Set view = db.GetView("topten")
	Set nav = view.CreateViewNav
	Set entry = nav.GetFirstDocument
	Do While (Not entry Is Nothing)
		If (count = 0) Then
			Call doc.ReplaceItemValue("SubmissionList_Choices", entry.Document.GetItemValue("Subject")(0))
		Else
			Call doc.ReplaceItemValue("SubmissionList_" & count & "_Choices", entry.Document.GetItemValue("Subject")(0))
		End If
		count = count + 1
		Set entry = nav.GetNextDocument(entry)
	Loop
	
End Sub
Open in New Window
 
 
 
20080716-EE-VQP-32 / EE_QW_2_20070628