Ok, I’ve read through hundreds of posts, tried 4 different solutions from ‘the view’ from here, from sandbox from the web, from all over, and I still can’t get the damn thing to work right.
I’ve got a form that people will access via IE6, when the users are done filling out the form, there’s a place for them to address it and send it out. The form, in essense, is a meeting invitation.
When this was strictly a notes app, doing an address book dialog box for the SendTo field was a piece of cake, it worked without a hitch. Now that it needs to be web-enabled…I can’t get the dang thing to work.
I need to be able to pull up the People and/or the Groups entries from our PNAB and allow the user to choose the attendees. These can be seperate pulls, that’s not a problem. Currently our PNAB has 170,000 documents in the people view and over 35,000 documents in the groups view. So I exceed the 64K limit and the 1000 record limit for some of the solutions I’ve seen.
Most of the past two days I’ve been trying to implement the solution by Sunilkumar Vishwakarma that uses an agent called from a button. My Javascript is weak, I’ll be honest, but I followed all the instructions on how to install this solution and got back a variety of weird errors. Here’s the start of the instructions:
Please note that DBPath is a Computed For Display field on the form from where you wish to call the Web Address Book. The formula for DBPath field is
@ReplaceSubstring(@Subset(@DbName;-1);“\”;“/”)
Also, please note that screenWidth and screenHeight are variables to be defined in the JavaScript header section, as written below: (Note: screenWidth and screenHeight are used in openAddressDialogbox().)
var screenWidth = screen.width;
var screenHeight = screen.height;
Here’s the code for the AddressBook:
Javascript:
how to call:
openAddressDialogbox(document.forms[0].fieldName)
function openAddressDialogbox(element) {
window.nameElement = element ;
var popUpWidth = 342;
var popUpHeight = 400;
var popUpLeft = parseInt((screenWidth - popUpWidth)/2);
var popUpTop = parseInt((screenHeight - popUpHeight)/2);
var strNewWin = ‘/’ + document.forms[0].DbPath.value
and the error I’m getting is that document.forms[0].DbPath.value is null or not an object
Has anyone attempted this solution? Do you know if the DBPath field needs to be Passthru HTML? Do I need to store the form in the document, do I need to call a save of some sort before I call the agent? Any suggestions or pointers would be welcome. At this point, Im’ getting desperate, and 3 days past my deadline isn’t helping if you know what I mean.
Subject: Web Address Lookup —Again (I know it’s been done before but…)
You DbPath field needs to be an editable field visible to the browser to be readable from javascript. You can add type=“hidden” in the other field of the tab in field properties to hide it.
You can also do this:
var strNewWin = new String(location.href.slice(0, location.href.toLowerCase().indexOf(‘.nsf’)+4));
(this takes everything from the current location, to the left of the .nsf part )
Subject: RE: Web Address Lookup —Again (I know it’s been done before but…)
Fantastic! That worked …but only so far in that the pop up window opened. I got another error message, the common “HTTP 500 Internal Server Error” Page cannot be Displayed.
So far, this part of the code now works (thanks to Bjorn):
openAddressDialogbox(document.forms[0].DBPath)
function openAddressDialogbox(element) {
window.nameElement = element ;
var popUpWidth = 342;
var popUpHeight = 400;
var popUpLeft = parseInt((screenWidth - popUpWidth)/2);
var popUpTop = parseInt((screenHeight - popUpHeight)/2);
var strNewWin = ‘/’ + document.forms[0].DBPath.value + ‘/agtWebNAB?OpenAgent&default=’ + escape(element.value);
//alert(strNewWin);
var newWin = window.open( strNewWin , ‘newWin’, ‘toolbar=no,location=no,directories=no,status=yes,resizable=no,scrollbars=no,menubar=no,top=’+popUpTop+‘,left=’+popUpLeft+‘,width=’+popUpWidth+‘,height=’+popUpHeight );
}
You can see from the code that the popup window is calling the agtWebNAB?OpenAgent
The agent looks like this (it’s long, sorry, I’ll post my questions below the agent code at the bottom of this page, thanks for reading this far)
’ print the JavaScript functions called in the buttons
Print |<SCRIPT LANGUAGE=JavaScript>
|
’ code to populate options starts
Dim session As NotesSession
Dim db As NotesDatabase
Dim ndb As NotesDatabase
Dim books As Variant
Dim selectedBook As String
Dim docContext As NotesDocument
Dim vw As NotesView
Dim nav As NotesViewNavigator
Dim entry As NotesViewEntry
Set session = New NotesSession
Set docContext = session.DocumentContext
books = session.AddressBooks
Dim h_QueryString_Decoded As String
h_QueryString_Decoded = Cstr(docContext.Query_String_Decoded(0))
Dim strNdbServer As String
strNdbServer = extractParameter(h_QueryString_Decoded,"addressBook")
Dim namServer As NotesName
If strNdbServer = "" Then
’ get names.nsf database on current server
Set ndb = session.getDatabase("","names")
Else
‘’ get names.nsf database on selected server
Set ndb = session.getDatabase(strNdbServer,"names")
End If
Set namServer = New NotesName(ndb.Server)
'Continue Printing
Print "<TR VALIGN=top><TD CLASS=BLUE WIDTH=322><DIV ALIGN=center><B>Names on " & namServer.Common & "</B></DIV></TD></TR>"
Print "<TR VALIGN=top><TD CLASS=GREY WIDTH=322><DIV ALIGN=center>"
If Not ndb.IsOpen Then
Call ndb.Open("","names")
End If
’ get the People view and create a ViewNavigator object for navigating the entries in the view
Set vw = ndb.getView("$VIMPeopleAndGroups")
Set nav = vw.createViewNav()
’ get the first document in view
Set entry = nav.getFirstDocument()
’ initialize variables required later on
Dim pos As Integer
Dim maxCount As Integer
Dim l_first As String
Dim l_prev As String
Dim l_next As String
Dim l_last As String
Dim l_search As String
’ variable for maximum names to be shown as options in the SELECT tag
maxCount = 200
’ variable for the actions passed in the URL
l_first = "first"
l_prev = "prev"
l_next = "next"
l_last = "last"
l_search = "search"
Dim defaultSelection As String
Dim startParameter As String
Dim start As Integer
Dim action As String
’ gets the default value for selection passed in the URL
startParameter = extractParameter(h_QueryString_Decoded,"start")
start = 1
If Isnull(startParameter) Or startParameter="" Then
start = 1
pos = 1
Else
start = startParameter
pos = start
End If
’ Gets the button clicked on the window
action = extractParameter(h_QueryString_Decoded,"act")
If Isnull(action) Then
’ Keep the entry as first document
Elseif action=l_first Then
’ Keep the entry as first document
Elseif action=l_prev Then
pos = start - maxCount
If pos<1 Then
pos=1
End If
Set entry = nav.getNth(pos)
If entry Is Nothing Then
Set entry = nav.getFirstDocument()
End If
Elseif action=l_search Then
Set entry = vw.getEntryByKey(extractParameter(h_QueryString_Decoded,"query"), False)
If entry Is Nothing Then
pos = start
Else
pos = entry.getPosition(".")
End If
Set entry = nav.getNth(pos)
Elseif action=l_next Then
pos = start + maxCount
Set entry = nav.getNth(pos)
If entry Is Nothing Then
Set entry = nav.getLastDocument()
pos = entry.getPosition(".")
End If
Elseif action=l_last Then
Set entry = nav.getLastDocument()
pos = entry.getPosition(".")
pos = pos - maxCount + 1
If pos < 1 Then
pos = 1
End If
Set entry = nav.getNth(pos)
Else
’ Keep the entry as first document
End If
Dim varTemp As Variant
varTemp = Evaluate(|@Left("| & h_QueryString_Decoded & |";"OpenAgent") + "?OpenAgent"|)
’ iterate through the view entries till end of view or maximum count in the options list is reached
Dim eType As String
Dim vFieldName As String
Dim person As NotesName
While (Not entry Is Nothing And (count<maxCount))
eType = entry.document.getItemValue("Type")(0)
If eType = "Person" Then
vFieldName = "FullName"
Else
vFieldName = "ListName"
End If
’ creates a Name object for getting username in abbreviated format
Set person = session.CreateName(entry.document.getItemValue(vFieldName)(0))
If eType = "Person" Then
If count Mod 2 = 0 Then
Print "<OPTION CLASS='EVEN' VALUE='" & person.Common & "' TITLE='" & person.Abbreviated & "'>" & person.Common & "</OPTION>"
Else
Print "<OPTION CLASS='ODD' VALUE='" & person.Common & "' TITLE='" & person.Abbreviated & "'>" & person.Common & "</OPTION>"
End If
Else
Print "<OPTION CLASS='GROUP' VALUE='" & person.Common & "' TITLE='" & person.Abbreviated & "'>[ " & person.Common & " ]</OPTION>"
End If
count = count + 1
Msgbox "[ApplicationName] : Error in " & "agtWebNAB" & " at line number " & Erl
Msgbox "[ApplicationName] : Error Number is " & Err
Msgbox "[ApplicationName] : Error Description is " & Error
End Sub
Public Function ExtractParameter ( QueryString As String, ParameterName As String) As String
On Error Goto errorHandler
ParameterName = ParameterName & "="
Dim startPosition, endPosition, queryStringLength, parameterLength As Integer
Dim parameterValue As String
queryStringLength = Len ( QueryString )
parameterLength = Len ( ParameterName )
startPosition = Instr ( 1, QueryString, ParameterName, 5 )
If startPosition = 0 Then
parameterValue = ""
Else
startPosition = startPosition + parameterLength
endPosition= Instr ( startPosition, QueryString, "&" )
If ( endPosition = 0 ) Then
endPosition = queryStringLength + 1
parameterLength = endPosition - startPosition
parameterValue = Mid ( QueryString, startPosition,parameterLength )
Elseif ( endPosition <> 0 ) Then
parameterLength = endPosition - startPosition
parameterValue = Mid ( QueryString, startPosition,parameterLength )
End If
End If
ExtractParameter = parameterValue
Exit Function
errorHandler:
Msgbox "[ApplicationName] : Error in " & "ExtractParameter()" & " at line number " & Erl
Msgbox "[ApplicationName] : Error Number is " & Err
Msgbox "[ApplicationName] : Error Description is " & Error
End Function
My thought is that this code probably works fine. Because of the Page Cannot Be Displayed error, I’m more likely missing a setting or a call somewhere. The script didn’t kick out any errors in the debugging process, and this solution has been floating around the web for a while so I’m more inclined to believe the code is solid.
Why would this agent not be able to open the popup in a new window? Is there a popup setting I’m missing? Could it be a browser setting or a notes setting? Thanks in advance for the help!
Subject: Web Address Lookup —Again (I know it’s been done before but…)
There is a view named “People” in the Address Book db. I think the 3rd or the 4th column has the address of the employees. Use dbcolumn to get the mail address, that works in web.
To get the web ids, press Ctrl + Shift then goto to get to a manually hidden view ($NamesFieldLookup) . Dbcolumn the first column. It will have double values. Omit the ones without @compname. Hope this works.
Subject: Web Address Lookup —Again (I know it’s been done before but…)
I may be biased but my personal favorite for a web nab picker can be found in a post on this blog site (sorry can’t give you a specific address - I can’t access the site from my current client):
Scott went through a bit of work tweaking the solution to make sure it looks and functions as close as possible to the NAB picker included in Notes. It’s easy to implement and runs fast even on large address books.
Subject: RE: Web Address Lookup —Again (I know it’s been done before but…)
Scott’s site is full of amazing tips and tricks, I just spent two hours reading through his place. I haven’t found the script yet for the NAB over the web but dang! this is a treasure chest of really cool stuff! If you could find the link to the Web NAB info lateron when your not at your client site and post it back here for me that’d be great, thanks. Until then I’m going to keep hunting around this site. I already see two things I’m gonna try to implement as well, great tips!