Andrew Pollack's Blog

Technology, Family, Entertainment, Politics, and Random Noise

Domino Technote - Undocumented function plus cool code lets you get the current location name, thus any data from the current location in pure formula language.

By Andrew Pollack on 07/01/2006 at 11:24 PM EDT

I don't post technotes like this often, but rest assured fans of mine, the old man still knows a few things. Someone we all know and love was bouncing a problem off me. He needed to lookup the currently active location document name. @Environment wouldn't work because you can't lookup non-user variables. The tricky part is that it had to be all formula language.

He tipped me to an undocumented function "@LocationGetInfo". After dumping the mail6.ntf and pernames.ntf to dxl, I came up with only a few parameters for that function.


None of these did what we wanted. After some hacking and a little educated guesswork, I came up with this one:


That was magic. Once we had that, I quickly wrote this formula to get the name. With the name, you can lookup any field on the document of course.

n := @Text(@LocationGetInfo([UNID]));
locList := @DbColumn("":"NoCache" ; "": "Names.nsf" ; "Locations"; 1);
@For( x := 1 ; x <= @Elements(LocList) ; x := x+1 ;
t := @DbLookup("":""; "":"Names.nsf"; "Locations"; @Subset(@Subset(loclist; x) ; -1) ; "Name" ; [ReturnDocumentUniqueID]);
@If(n = @Text(t) ; @Do(@Set("LocationName"; @Subset(@Subset(loclist; x) ; -1) ); x := @Elements(loclist) + 1 ) ; "")

Looking at this, the first line gets the unid of the current location. Next, we get a list of all the locations. Then we lookup each location in order and check the unid. When we have a match, we set the value of the name to our internal variable "locationName" and then also set x to larger than the list of locations so we don't do any more lookups than we have to.

There are  - loading -  comments....

My own thoughts on this are...By Rock on 07/01/2006 at 11:46 PM EDT
Hey, I'm the guy who asked Andrew for the brainstorming on this :)

And of course, I had to see if I could "one plus" his brilliant formula - so I
did, using @Transform:

n := @Text(@LocationGetInfo([UNID]));
loclist := @DbColumn("" : ""; "" : "Names.nsf"; "Locations"; 1);
location := @Trim(@Transform(loclist; "curloc"; @If(n = @Text(@DbLookup("":"";
"":"Names.nsf"; "Locations"; curloc ; 1 ; [ReturnDocumentUniqueID])); curloc;

Basically the logic is the same, just less code. It does the lookup like
before, but if it doesn't match it makes it an empty string; if it matches, it
returns the location name. Then the resulting list is trimmed to remove the

GREAT stuff, Andrew - thanks for the help :)

Rock's code only LOOKS better....By Andrew Pollack on 07/02/2006 at 08:55 AM EDT

If you compare these, Rock's code doesn't exit after finding the location, so
it does a lookup for every doc in the view, not just the ones until it finds
the right location document. It also assigns a value to a string list for
every lookup, then at the end compares each value to see if its a null string
when it does the @Trim()

I'll stick with mine, Rock. Thanks!
Why not just use @GetDocField( documentUNID ; fieldName ) ?By Craig Wiseman on 07/03/2006 at 08:32 AM EDT
Since you get the UNID, why not just use:

@GetDocField( documentUNID ; "Name" ) to get the name and any other desired
Not that I can test this, b/c:By Craig Wiseman on 07/03/2006 at 08:45 AM EDT
Whenever I try to run
n := @Text(@LocationGetInfo([UNID]));

I get a "Document not found" dialog. Notes Client 7.0.1 on WinXPsp2.
Interesting. It must be a matter of context.By Andrew Pollack on 07/03/2006 at 09:55 AM EDT
I'm using 7.0.1 and no problem. The button is in the rich text field of an open
mail document. Perhaps you have to save the document first, or must have a
currently selected document.
Ran ncompact -c -i on my names.nsf and it works now...By Craig Wiseman on 07/03/2006 at 05:39 PM EDT
@GetDocField only works in the current database. Location is in local directory.By Andrew Pollack on 07/03/2006 at 09:54 AM EDT
Your location document is in the local names.nsf file, where this button or
formula may very well be located in a database other than that.

You can use @GetDocField if you first do @Command([FileOpenDatabase]...) then
@UpdateformulaContext but then you've actually opened the other file -- visibly
- and you have to do @Command([fileclosewindow]) followed by
@UpdateformulaContext to continue -- and if there is any problem along the way,
you're closing the wrong window.

duh....By Craig Wiseman on 07/03/2006 at 03:55 PM EDT
I knew that, not that I let my brain interfer with my typing.
I'm still working out why
won't work for me.

I have a simple 'code store' database. I have a saved document with a a button
with just

n := @Text(@LocationGetInfo([UNID]));
@Prompt([Ok];"n ";n )

in it. Doesn't work.

I just put the button in an email, doesn't work. I've got something mangled

Use @LocationGetInfo([FullName]) By Jens Winkelmann on 08/18/2006 at 08:19 AM EDT
You can use this @Function @LocationGetInfo([FullName])
Fantastic!By Andrew Pollack on 08/18/2006 at 08:57 AM EDT
I've tested it, it works. It will become a blog entry.
re: Use @LocationGetInfo([FullName]) By Wolfgang Hass on 05/25/2009 at 10:01 AM EDT
Great, I love it. Never would have tested that... FullName is associated with
other stuff. But it works!!!!
Too bad LotusScript is out and reading system environment variablesBy Lars Berntrop-Bos on 08/22/2006 at 04:51 AM EDT
Using LS you can do:
Private Sub update_current_location
Dim ses As New NotesSession
Dim v As Variant
EnvLocation = ses.GetEnvironmentString(ENV_LOCATION, True)
v = Split(EnvLocation, LOCATION_DELIM)
currentLocation = v(0)
End Sub ' update_current_location

I use this in app initialization and SetEnv a user notes.ini var with it so we
can use it in formulalanguage.

Other Recent Stories...

  1. 01/26/2023Better Running VirtualBox or VMWARE Virtual Machines on Windows 10+ Forgive me, Reader, for I have sinned. I has been nearly 3 years since my last blog entry. The truth is, I haven't had much to say that was worthy of more than a basic social media post -- until today. For my current work, I was assigned a new laptop. It's a real powerhouse machine with 14 processor cores and 64 gigs of ram. It should be perfect for running my development environment in a virtual machine, but it wasn't. VirtualBox was barely starting, and no matter how many features I turned off, it could ...... 
  2. 04/04/2020How many Ventilators for the price of those tanks the Pentagon didn't even want?This goes WAY beyond Trump or Obama. This is decades of poor planning and poor use of funds. Certainly it should have been addressed in the Trump, Obama, Bush, Clinton, Bush, and Reagan administrations -- all of which were well aware of the implications of a pandemic. I want a military prepared to help us, not just hurt other people. As an American I expect that with the ridiculous funding of our military might, we are prepared for damn near everything. Not just killing people and breaking things, but ...... 
  3. 01/28/2020Copyright Troll WarningThere's a copyright troll firm that has automated reverse-image searches and goes around looking for any posted images that they can make a quick copyright claim on. This is not quite a scam because it's technically legal, but it's run very much like a scam. This company works with a few "clients" that have vast repositories of copyrighted images. The trolls do a reverse web search on those images looking for hits. When they find one on a site that looks like someone they can scare, they work it like ...... 
  4. 03/26/2019Undestanding how OAUTH scopes will bring the concept of APPS to your Domino server 
  5. 02/05/2019Toro Yard Equipment - Not really a premium brand as far as I am concerned 
  6. 10/08/2018Will you be at the NYC Launch Event for HCL Domino v10 -- Find me! 
  7. 09/04/2018With two big projects on hold, I suddenly find myself very available for new short and long term projects.  
  8. 07/13/2018Who is HCL and why is it a good thing that they are now the ones behind Notes and Domino? 
  9. 03/21/2018Domino Apps on IOS is a Game Changer. Quit holding back. 
  10. 02/15/2018Andrew’s Proposed Gun Laws 
Click here for more articles.....

pen icon Comment Entry
Your Name
*Your Email
* Your email address is required, but not displayed.
Your thoughts....
Remember Me  

Please wait while your document is saved.