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. 03/21/2018Domino Apps on IOS is a Game Changer. Quit holding back.BOOM. This will be as important for the platform as Traveler. If your company has ditched Notes and Domino, I feel sorry for you. For companies that do use Notes/Domino this is a game changer and Apple should be paying attention. Here's why: There are hundreds of little Notes client applications you'd never spend the time and money to build and deploy for your internal user base on IOS that we use Notes for all the time (those of us still using it). Now, those are suddenly ALL available on the iPad. ...... 
  2. 02/15/2018Andrew’s Proposed Gun LawsThese are my current thoughts on gun laws that would radically change the culture and safety of gun ownership in the United States without removing the rights of gun owners or compromising their privacy rights. * Please feel free to link to, or just copy, these ideas. It would be wonderful to see them spread widely and eventually become the basis for something to rally around and become legislation. Update: 3/3/2018 I added #7, increasing the age to purchase. Update: 4/27/2018 Please be aware that I am not ...... 
  3. 05/05/2016Is the growing social-sourced economy the modern back door into socialism?Is the growing social-sourced economy the modern back door into socialism? I read a really insightful post a couple of days ago that suggested the use of social network funding sites like “Go Fund Me” and “Kickstarter” have come about and gained popularity in part because the existing economy in no longer serving its purpose for anyone who isn’t already wealthy. Have the traditional ways to get new ventures funded become closed to all but a few who aren’t already connected to them and so onerous as to make ...... 
  4. 04/20/2016Want to be whitelisted? Here are some sensible rules for web site advertising 
  5. 12/30/2015Fantastic new series on Syfy called “The Expanse” – for people who love traditional science fiction 
  6. 10/20/2015My suggestion is to stay away from PayAnywhere(dot)com  
  7. 08/07/2015Here is one for you VMWARE gurus - particularly if you run ESXi without fancy drive arrays 
  8. 08/06/2015The Killer of Orphans (Orphan Documents) 
  9. 06/02/2015Homeopathic Marketing: Traveler on my Android is now calling itself VERSE. Allow me to translate that for the IBM Notes community... 
  10. 03/17/2015A review of British Airways Premium Economy Service – How to destroy customer goodwill all at once 
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.