Thursday, February 23, 2006

Is it Thursday again already? Show-n-tell

Just a quick little tip today. We have a lot of forms that contain dialog lists whose choices can be set in a profile document by an "administrative user." Occasionally they want to allow regular users to be able to add values to those fields, but for various reasons we don't want to give regular users unrestricted access to the profile document. Here's how we do it:

1. The dialog list field should be set to allow values not in list.
2. Create a hidden field on the form that uses the same @GetProfileField formula as the dialog list.
3. On querysave, test value of dialog against values in hidden field with this code:


FIELD fileType:=fileType;
FIELD fileTypeOld:=fileTypeOld;

@If(@IsNotMember(fileType; fileTypeOld); @SetProfileField("choicesForm"; "fileTypeChoices"; fileTypeOld : fileType); @Return("") )


Show-n-tell+thursday

Wednesday, February 22, 2006

More vanishing MS content

I wonder about Microsoft's control over their employees... every time something is posted to their website that generates not-so-positive interest, that content suddenly vanishes. Either "it was a private beta" or "it was posted prematurely."

Isn't there some kind of limitations to who can post things to their website? You know, to make sure that the stuff that gets posted actually should have been? Maybe FrontPage doesn't require authentication...

Thursday, February 16, 2006

Code to format formula language

After the last post, I'm thinking my next side project is extending Julian and Joe's code to allow formatting of formula, as well as LotusScript...

Show-n-Tell Thursday


Taking up the call to arms, here's my tip. Not as impressive as many, and quite a hack to boot, but it solved a problem we had.

Issue: our field users' mail files were getting huge, and needed to be compacted on a regular basis. But many of them didn't even realize they had a server replica; all their work is done locally, with replication settings that are just a magic button to them. Asking them to open their server replica to compact it would cause major panic. I don't know why there wasn't a server task in place to handle this; I'm not an admin. In any case, there's a lovely Compact method available in the NotesDatabase class, but it only works on local replicas. So how do we get these users to manually compact a server-based replica they're not even aware of?

Solution:

1. Put an action button in my Inbox (or any other view/folder) with this code:

server := @Name([CN]; @Subset(@DbName; 1));
serverFile:="mail\\" + @Subset(@DbName; -1);

@If(
server!=""; @Command([FileDatabaseCompact]);
@Do(
@Environment("CompactNow"; "true");
@Command([FileOpenDatabase]; "yourServer" : serverFile ; "($Inbox)"; "" ; "1" ; "1" )
)
)

This first tests to see if the database is local or server; if it's server it does the compact; if it's local it sets an environment variable and opens the server database. Again, I'd need to add a few lines of code to determine the correct mail server for each user (just a dblookup to their local names.nsf to get their location document, I think.)


2. In the Database Script PostOpen event, I put the following code:

x:=@Environment("CompactNow");
server:=@Subset(@DbName; 1);

@If(server!="";

@If(x="true";
@Do(@Command([FileDatabaseCompact]);
@Command([FileCloseWindow]));
""
);
"")

Every time the mail database opens, it tests to see if it's server or local. If it's local it does nothing. If it's server, it checks to see if the environment variable that was set by the button is equal to "true". If it is, it runs the compact and immediately closes the database. If it's not "true", it does nothing (just leaves the database open for people who normally work in-office with server replicas.)


3. In the Database Script QueryClose event, I put the following code:

@Environment("CompactNow"; "")

This ensures that the variable is cleared out when the script from PostOpen closes the database so that the next time the user opens it, it doesn't automatically compact.

At least in my tests, all of this happens so quickly that you don't actually see the server replica open at all. It will take a few minutes for the Percent Used number on the server replica to adjust, but this is the case even when you run compact manually using the Compact button on the database properties box.


Show-n-tell Thursday