<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
<channel>
<title>CodeStore.net comments on "Odd Behaviour of LotusScript Function Not Returning NotesDocument"</title>
<description>Replies to blog "Odd Behaviour of LotusScript Function Not Returning NotesDocument" on codestore.net.</description>
<link>http://www.codestore.net/</link>
<lastBuildDate>Thu, 26 Aug 2010 00:05:04 -0500</lastBuildDate>
<atom:link href="http://www.codestore.net/store.nsf/blog.xml?Open=20080208" rel="self" type="application/rss+xml" />

<item>
	<title>Reply from Sam Sirry</title>
	<pubDate>Thu, 26 Aug 2010 00:05:04 -0500</pubDate>
	<author>Sam Sirry</author>
	<description><![CDATA[ 
		<p>By the way, I tried this trick and some-how it worked like magic:</p>
		<p>set db = session.getdatabase(dbname)</p>
		<p>set doc = db.getdocumentbyid(doc_id) 'or use lookup or anything..</p>
		<p>url = doc.notesurl</p>
		<p>set db = nothing</p>
		<p>set doc = session.resolve(url)</p>
		<p>with a function containing the above code, I could return the document object and use it in another procedure.</p>
		<p>of course, this is not practical if, for example, you're working with a set of documents to return them in a documentcollection or an array.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=46E8D1827F4CA75F8625778B001BEDD2"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_46E8D182</link>
</item><item>
	<title>Reply from Sam Sirry</title>
	<pubDate>Wed, 25 Aug 2010 23:55:30 -0500</pubDate>
	<author>Sam Sirry</author>
	<description><![CDATA[ 
		<p>Yes, Ferry. It's still happening in my part of the world too ;p  in 2010!</p>
		<p>This used up 2 full days of head-scratching before I finally found this page through Google.</p>
		<p>Clearly I don't often work in multi-db set-ups this way...</p>
		<p>Thanks everyone!</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=B048B9DB1FED0FD78625778B001B0DA5"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_B048B9DB</link>
</item><item>
	<title>Reply from gdelpierre</title>
	<pubDate>Thu, 04 Mar 2010 05:23:05 -0600</pubDate>
	<author>gdelpierre</author>
	<description><![CDATA[ 
		<p>You need to declare in global your database,session in which  your return document is.</p>
		<p>For example i've a function that create a lock in an external DB, then another function that will check if a lock exist in this external DB (here it's sdoc variable in database DB). If my database DB is not declared in global, it doesn't work.</p>
		<p></p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=42E3F319C38DD381862576DC003E89F5"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_42E3F319</link>
</item><item>
	<title>Reply from Ferry Kranenburg</title>
	<pubDate>Tue, 26 Jan 2010 04:44:42 -0600</pubDate>
	<author>Ferry Kranenburg</author>
	<description><![CDATA[ 
		<p>This is an old blog I know, but I'm sooo glad I found this via google! The same problem was driving me crazy too!</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=78EC013F54840F1D862576B7003B0668"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_78EC013F</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>Tony. I think the big difference is that you're running the code locally in the client and I'm talking solely about WQ agents on the web. That's probably why we're seeing different results.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=A5D3390D69839636852573EC002C9E2D"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_A5D3390D</link>
</item><item>
	<title>Reply from Remko</title>
	<pubDate></pubDate>
	<author>Remko</author>
	<description><![CDATA[ 
		<p>Try this:</p>
		<p>public Class NAB</p>
		<p>Private vw As NotesView</p>
		<p>Private db As NotesDatabase</p>
		<p>Private isValid As Boolean</p>
		<p>Sub new (sSV As String, sDB As String)</p>
		<p>Set db = New NotesDatabase(sSV, sDB)</p>
		<p>If db.IsOpen Then</p>
		<p>Set vw = db.GetView("($VIMPeople)")</p>
		<p>isValid = True</p>
		<p>End If</p>
		<p>End Sub</p>
		<p>Function getUserDoc(sUsername As String) As NotesDocument</p>
		<p>If Me.isValid Then</p>
		<p>Set getUserDoc =  vw.GetDocumentByKey( sUsername, True )</p>
		<p>Else</p>
		<p>Set getUserDoc = Nothing</p>
		<p>End If</p>
		<p>End Function</p>
		<p>End Class</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=D96E49739BAFE610852573EC0027D550"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_D96E4973</link>
</item><item>
	<title>Reply from Tony Palmer</title>
	<pubDate></pubDate>
	<author>Tony Palmer</author>
	<description><![CDATA[ 
		<p>In the Designer Help - LotusScript/COM/OLE classes  in the 'Using an Object' the following is at the bottom.</p>
		<p>"When you delete a Domino object, any contained objects are lost. For example, if you delete or close a NotesDatabase object, any NotesDocument objects in that database to which you refer are deleted."</p>
		<p>So I went back to the code. In the list of variables after I set the db to nothing and delete the view they are both empty. However, the document still has a reference to its parent database, that you can then browse the views and isOpen = true. Strange.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=130BD4623AAC1B46852573EB00824E81"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_130BD462</link>
</item><item>
	<title>Reply from Tony Palmer</title>
	<pubDate></pubDate>
	<author>Tony Palmer</author>
	<description><![CDATA[ 
		<p>@Stan</p>
		<p>My mistake, copied the wrong lss. However,</p>
		<p>I believe that once you have a handle to the object then you can pass that object to other functions, regardless of it's relationship in the class hierarchy (I'm not sure about this reference chain).</p>
		<p>To check my sanity I tried the following - which also worked.</p>
		<p>'jsJake: </p>
		<p>Option Public</p>
		<p>Function GetUserDocument(username As String) As NotesDocument</p>
		<p>Dim NAB As New NotesDatabase("", "names.nsf")</p>
		<p>Dim UserView As NotesView</p>
		<p>Dim tmp As NotesDocument</p>
		<p>If NAB.IsOpen Then</p>
		<p>Set UserView = NAB.GetView("($Users)")</p>
		<p>If UserView Is Nothing Then</p>
		<p>Set GetUserDocument = Nothing</p>
		<p>Exit Function</p>
		<p>End If</p>
		<p>Else</p>
		<p>Set GetUserDocument = Nothing</p>
		<p>Exit Function</p>
		<p>End If</p>
		<p>'TESTING</p>
		<p>Set tmp = UserView.GetDocumentByKey(username, True)</p>
		<p>Print tmp.FullName(0) 'This prints ok and finds right user!</p>
		<p>Print "Docid :"+tmp.UniversalID</p>
		<p>'END TESTING</p>
		<p>' REMOVAL OF THE REFERENCE CHAIN</p>
		<p>Print ("removing database from scope")</p>
		<p>Set NAB = Nothing</p>
		<p>' Delete NAB - this crashes the client</p>
		<p>Print ("removing view from scope")</p>
		<p>Delete UserView</p>
		<p>Print tmp.FullName(0) 'This prints ok and finds right user!</p>
		<p>Print "Docid :"+tmp.UniversalID</p>
		<p>Set GetUserDocument = tmp</p>
		<p>End Function</p>
		<p>So even when I explicitly set the view and database to nothing  it to nothing seems to work and keep the document object. Interestingly, I tried both delete and setting to nothing and deleting the NAB object crashes the 8.0.0 client.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=915B6A80B5FF0B81852573EB007E6719"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_915B6A80</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>How come the chain can survive if the View is global and the database isn't? If that can happen why can't the document survive too? Odd.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=9B49CF0F0B647D21852573EB00410258"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_9B49CF0F</link>
</item><item>
	<title>Reply from Stan Rogers</title>
	<pubDate></pubDate>
	<author>Stan Rogers</author>
	<description><![CDATA[ 
		<p>@Tony -- UserView lives outside of the function in your example, so the reference chain is alive outside of the function.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=07A89A871C03D097852573EB003B7374"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_07A89A87</link>
</item><item>
	<title>Reply from Tony Palmer</title>
	<pubDate></pubDate>
	<author>Tony Palmer</author>
	<description><![CDATA[ 
		<p>Hi Jake,</p>
		<p>I just tried your code, as passing around notes document objects without the database being in scope is something I've always done - and not had a problem with. I was thinking all day - have I been  keeping the db's in scope by luck...nah, surely not. So with nothing better to do on a Saturday night, than settle my curiosity - I've imported your code into ND8 and it works as expected. I did make a couple of changes like adding the Option Public in the Library - if you don't you should get an error in the Agent during compile time. The other change is that I switched out the username to be a value. Then finally, I checked that the documents UNID was the same for both getdocumentbykey calls. I'd normally would have done what pedro suggested, rather than calling the getdocumentbykey multiple times.</p>
		<p>You've probably done this already, but try setting the username to a literal value to see if you get any different results, then try a local names.nsf.</p>
		<p>I've exported the code below, but I can send you  a zipped copy of the db - if you want.</p>
		<p>Not sure if this helps you or not - but I can sleep easy tonight :-)</p>
		<p>'jsJake: </p>
		<p>Option Public</p>
		<p>Dim UserView As NotesView</p>
		<p>Dim tmp As NotesDocument</p>
		<p>Function GetUserDocument(username As String) As NotesDocument</p>
		<p>Dim NAB As New NotesDatabase("", "names.nsf")</p>
		<p>If NAB.IsOpen Then</p>
		<p>Set UserView = NAB.GetView("($Users)")</p>
		<p>If UserView Is Nothing Then</p>
		<p>Set GetUserDocument = Nothing</p>
		<p>Exit Function</p>
		<p>End If</p>
		<p>Else</p>
		<p>Set GetUserDocument = Nothing</p>
		<p>Exit Function</p>
		<p>End If</p>
		<p>'TESTING</p>
		<p>Set tmp = UserView.GetDocumentByKey(username, True)</p>
		<p>Print tmp.FullName(0) 'This prints ok and finds right user!</p>
		<p>Print "Docid :"+tmp.UniversalID</p>
		<p>'END TESTING</p>
		<p>Set GetUserDocument = UserView.GetDocumentByKey(username, True)</p>
		<p>End Function</p>
		<p>'Development \ Testing Jake: </p>
		<p>Use "jsJake"</p>
		<p>Sub Initialize</p>
		<p>Dim UserDoc As NotesDocument</p>
		<p>Set UserDoc = GetUserDocument("jake")</p>
		<p>If UserDoc Is Nothing Then</p>
		<p>Print "Can't find it!"</p>
		<p>Else</p>
		<p>Print "Found it!" + Userdoc.Fullname(0)</p>
		<p>Print "Doc id:"+Userdoc.UniversalID</p>
		<p>End If</p>
		<p>End Sub</p>
		<p>Sub Terminate</p>
		<p>End Sub</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=5ACEE941CE94C7D7852573EA003BA379"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_5ACEE941</link>
</item><item>
	<title>Reply from Kirk Stoner</title>
	<pubDate></pubDate>
	<author>Kirk Stoner</author>
	<description><![CDATA[ 
		<p>There are three very simple lines of code that will make this work for you:</p>
		<p>1 and 2: In the Declarations of the script library:</p>
		<p>Public sess as NotesSession</p>
		<p>Public dbThis as NotesDataBase</p>
		<p># 3 - Declare your function as public (you should specify "Option Public" in script lib options if it is not already there)</p>
		<p>Public Function GetUserDocument(username as String) As NotesDocument..</p>
		<p>As the session and current database are very commonly used in many global functions and subs, I take this a step further by declaring both session and database globally and then intialiizing them in the Intialize Sub of my global script lib. This negates the need to intialize them any number of different places or having to test them for Nothing over and over  (testing for isOpen and isValid is recommended in your Initialze sub following the set statements), they are there ready to use by any function or sub within the library itself as well as any form, agent or action that 'use's that script lib</p>
		<p>defaultLib</p>
		<p>Options</p>
		<p>Option Public</p>
		<p>Declarations</p>
		<p>Public sess as NotesSession</p>
		<p>Public dbThis as NotesDatabase</p>
		<p>Initialize</p>
		<p>Set sess = New NotesSession</p>
		<p>Set dbThis = sess.CurrentDatabase</p>
		<p>If not ( dbThis.IsOpen ) Then</p>
		<p>....error handling...</p>
		<p>ElseIf not ( dbThis.IsValid ) Then</p>
		<p>....error handling...</p>
		<p>End If</p>
		<p>ANY code that uses defaultLib can reference sess or dbThis objects without worry as to whether or not they are set</p>
		<p>By declaring Function GetUserDocument as Public, the object it returns is available globally as well.</p>
		<p>Explcit declaration and initialization or destruction of any variable definitely falls under best practice guidelines.</p>
		<p>So, I talked about the pros of this approach, here's the cons:</p>
		<p>1) Any code that uses defaultLib, takes the performance hit of declaring and initializing those two class objects (sess and dbThis).</p>
		<p>2) If this code breaks for any reason, any code that uses is broken as well (we all know and respect the corruption factor of reusable code I'm sure).</p>
		<p>Peace</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=EC04625B8CDB7AE7852573EA0022C380"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_EC04625B</link>
</item><item>
	<title>Reply from Andre Guirard</title>
	<pubDate></pubDate>
	<author>Andre Guirard</author>
	<description><![CDATA[ 
		<p>I have to admit that I am lazy and often let functions return the default (Nothing, 0, False, "" or Empty, depending on datatype). However, setting it explicitly does make for better readability. Not everyone has these memorized.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=8693157BBAF4D19F852573EA000E63DA"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_8693157B</link>
</item><item>
	<title>Reply from Tommy Valand</title>
	<pubDate></pubDate>
	<author>Tommy Valand</author>
	<description><![CDATA[ 
		<p>Simple way to verify for yourself:</p>
		<p>Function test As NotesDocument	</p>
		<p>End Function</p>
		<p>--</p>
		<p>If test() Is Nothing Then</p>
		<p>Msgbox "Test is Nothing"</p>
		<p>Else</p>
		<p>Msgbox "Test is something"</p>
		<p>End If</p>
		<p>--</p>
		<p>In my limited experience, a Function always returns an uninitialized variable of it's return type.</p>
		<p>Function test As String</p>
		<p>End Function</p>
		<p>test() -&gt; ""</p>
		<p>Dim testStr As String</p>
		<p>testStr -&gt; ""</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=185B0A81FC9D9938852573E90066DFEE"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_185B0A81</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>Dunno Tommy. Inexperience I guess. I assumed you had to have a line that set the result to the name of the function at some point in the proceedings. I'll take you word for it that you don't and maybe change it...</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=B0D13BA77CC2568E852573E90064F7CD"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_B0D13BA7</link>
</item><item>
	<title>Reply from Tommy Valand</title>
	<pubDate></pubDate>
	<author>Tommy Valand</author>
	<description><![CDATA[ 
		<p>This is off-topic, but why:</p>
		<p>Set GetUserDocument = Nothing ?</p>
		<p>The result of the Function would still be Nothing if you just did:</p>
		<p>If UserView Is Nothing Then Exit Function</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=4470725FD2A0BCB2852573E90063A1D0"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_4470725F</link>
</item><item>
	<title>Reply from Jim Knight</title>
	<pubDate></pubDate>
	<author>Jim Knight</author>
	<description><![CDATA[ 
		<p>I think it works if you pass the db with it in the function as another object.</p>
		<p>Function GetUserDocument(NAB as notesdatabase, username as String) As NotesDocument</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=4FA0621438A61FFD852573E9006025B7"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_4FA06214</link>
</item><item>
	<title>Reply from Harkpabst Meliantrop</title>
	<pubDate></pubDate>
	<author>Harkpabst Meliantrop</author>
	<description><![CDATA[ 
		<p>Since Jake has his WebSession class already, making NAB a  property of that session sounds like a much better idea than dealing with ugly global variables. </p>
		<p>Preferably use lazy initialization on that one.</p>
		<p>Additionally, I fully agree to Julian. To both parts of his posting ... ;-)</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=89F494D093B1E13A852573E90055E87D"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_89F494D0</link>
</item><item>
	<title>Reply from Julian Robichaux</title>
	<pubDate></pubDate>
	<author>Julian Robichaux</author>
	<description><![CDATA[ 
		<p>I run into that one all the time. I can never seem to remember what the problem is from one time to the next either.</p>
		<p>Oh, and you might want to use NotesSession.AddressBooks to get the NAB instead. Just in case the database isn't names.nsf (happens sometimes).</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=8ED6D81A75D40187852573E900555C55"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_8ED6D81A</link>
</item><item>
	<title>Reply from Werner Götz</title>
	<pubDate></pubDate>
	<author>Werner Götz</author>
	<description><![CDATA[ 
		<p>In my code I always use a global list for caching NotesDatabases, NotesViews ... </p>
		<p>This has at least 2 advantages: It is faster when the database or view is used later again AND you have no problems with the Lotusscript memory management which in your case deletes the instance of the NotesDatabase because it is not more used and thereby deletes all "depending" objects too.</p>
		<p>In your case I would have (code not tested!)</p>
		<p>Dim gCacheObjects List As Variant</p>
		<p>Function NABDb As NotesDatabase</p>
		<p>Dim id</p>
		<p>id = "NABDb"</p>
		<p>If Not Iselement(gCacheObjects(id)) Then</p>
		<p>Set gCacheObjects(id) = New NotesDatabase(web.database.Server, "names.nsf")</p>
		<p>End If</p>
		<p>If Not gCacheObjects(id).IsOpen Then Error 32000, "NAB not available"</p>
		<p>Set NABDb = gCacheObjects(id) </p>
		<p>End Function</p>
		<p>Function NABView(viewname) As NotesView</p>
		<p>Dim id</p>
		<p>id = "NABView#" & Ucase(viewname)</p>
		<p>If Not Iselement(gCacheObjects(id)) Then</p>
		<p>Set gCacheObjects(id) = NABDb.GetView(viewname)</p>
		<p>End If</p>
		<p>If gCacheObjects(id) Is Nothing Then Error 32000, "NAB-View &lt;" & viewname & "&gt; not available"</p>
		<p>Call gCacheObjects(id).Refresh</p>
		<p>Set NABView = gCacheObjects(id) </p>
		<p>End Function</p>
		<p>Function GetUserDocument(username As String) As NotesDocument</p>
		<p>Dim id</p>
		<p>id = "UserDocument#" & Ucase(username)</p>
		<p>If Not Iselement(gCacheObjects(id)) Then</p>
		<p>On Error Resume Next</p>
		<p>Err = 0</p>
		<p>Set gCacheObjects(id) = NABView("($VIMPeople)").GetDocumentByKey(username, True)</p>
		<p>If Err &lt;&gt; 0 Then </p>
		<p>Set gCacheObjects(id) = Nothing</p>
		<p>Err = 0</p>
		<p>End If</p>
		<p>End If        </p>
		<p>Set GetUserDocument = gCacheObjects(id) </p>
		<p>End Function</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=B08C063E6927FAAB852573E90052E1BD"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_B08C063E</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>Scratch that last comment. It does work from the global web object.</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=30460A25F43B2501852573E900527C43"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_30460A25</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>Maybe not as simple as i'd thought. I tried to add the NAB variable to my "web" global WebSession object, like so:</p>
		<p>Class WebSession</p>
		<p>Public NAB As NotesDatabase</p>
		<p>Sub new</p>
		<p>Set Me.NAB = New NotesDatabase(Me.database.Server,"names.nsf")</p>
		<p>End Sub</p>
		<p>End Class</p>
		<p>set web= new WebSession()</p>
		<p>But using web.NAB in the GetUserDocument still doesn't work. Does the DB have to be an actual global variable in its own right?</p>
		<p>Jake</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=D6114C09907C8CA7852573E900522D44"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_D6114C09</link>
</item><item>
	<title>Reply from Pedro Quaresma</title>
	<pubDate></pubDate>
	<author>Pedro Quaresma</author>
	<description><![CDATA[ 
		<p>Does the result change if you replace</p>
		<p>Set GetUserDocument = UserView.GetDocumentByKey(username, True)</p>
		<p>with</p>
		<p>Set GetUserDocument = tmp</p>
		<p>?</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=AC9CF392EA1D1465852573E900514DB5"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_AC9CF392</link>
</item><item>
	<title>Reply from Sandra Noronha</title>
	<pubDate></pubDate>
	<author>Sandra Noronha</author>
	<description><![CDATA[ 
		<p>I've had my share of head scratching because of this one. I'm glad I could help. ;)</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=48FC246D7DA6E3F8852573E90051494A"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_48FC246D</link>
</item><item>
	<title>Reply from Jake Howlett</title>
	<pubDate></pubDate>
	<author>Jake Howlett</author>
	<description><![CDATA[ 
		<p>Aha. You won't believe this, but that did occur to me. Honestly. I just didn't think to test it.</p>
		<p>Looks like my global "web" object needs a new AddressBook property...</p>
		<p>Thanks Sandra!</p>

		<p><a href="http://www.codestore.net/store.nsf/reply?OpenForm&ParentUNID=1A2680E9776ABF38852573E90050C089"><img border="0" src="http://www.codestore.net/store.nsf/images/rss_reply.gif" alt="Click here to post a response" /></a></p>
	]]></description>
	<link>http://www.codestore.net/store.nsf/unid/BLOG-20080208?OpenDocument#DOC_1A2680E9</link>
</item>

</channel>
</rss> 
