GoogleIt Mail IT Print IT PermaLinkSnTT: Reliable @Formula View Actions (An Oldie, But A Goodie)
11:29:08 PM

This one came up on developerWorks this morning. I knew it had been a long time since I had first faced it, but I didn't realize that it was more than ten years until I tracked down a post I put in the Lotus BP Forum on April 5th, 1996! The issue? Let's say you have a view action button with a formula like this:


          FIELD foo := "Bar";


It works perfectly, until one day, one user tells you that it doesn't. You go to that user's workstation, and sure enough, it doesn't work. It runs without giving any error message, but it doesn't set the foo field to "bar". Why? This issue has been around for ten years, but do you know the answer, and the workaround? If not, read on.


The answer is that the user has the preview pane open. Maybe it's only a few pixels at the bottom of the screen, but it is open. Your view action button is running in the context of the open document, not in the context of the view, and the document is open in read mode. An action button in a form can't set a field if the document is open in read mode; and neither can an action button in a view.


Lotus acknowledged this as a "known issue" way back in '96 -- the early R4 days. They said it would be really hard to change this, and I guess that must have been an understatement, because ten years later it still works this way. I imagine that it's one of those "bug-for-bug compatability" things that can't be changed even if it is now possible to do so, because it might break applications.


So, how do you deal with this? One way is to create an agent with the FIELD Foo := "Bar" formula, and have your view action do a @Command to run the agent. That works, but I don't like that because your view action ran against only the document selected by the cursor. An agent will run against all selected documents. If your users are used to it just setting Foo to "Bar" in the current document, this is a change in behavior -- a risky change.


LotusScript might be the next thing you turn to. Instead of a having your action button invoke a simple formula agent, you could have it invoke a LotusScript agent that checks NotesDatabase.UnprocessedDocuments.count, and generates an error message if it is greater than 1, thereby avoiding the pitfall of running the formula agent. (The rest of the LotusScript is left as an exercise for the reader.) That works, and it's probably the most robust solution overall -- but it really feels like overkill to call a an agent in the cases where the preview pane isn't open. This really should have a solution in @formula language.


And it does. What you really need to do is detect whether the preview pane is open. You would happily use @IsDocBeingPreviewed, if it existed, but it doesn't. Still, there is a way. First, add a field called "isDocOpen" to the form (or forms) for documents in the view. Make it a computed field with this formula:


           @If(@IsDocBeingLoaded;"Y";@Unavailable)


Then change your action button formula as follows:


          @If(isDocOpen="Y";
          @Prompt([Ok];"Error";"You must close the preview pane before clicking this button");
          FIELD Foo := "Action Bar");
          @True


This is the pure @formula solution. It doesn't always set the Foo field, but it gives a helpful error message when it detects that the document is open in the preview pane.


Of course, you can combine the @formula solution with the LotusScript solution if you want. Just change the @Prompt to an @Command to invoke your LotusScript agent. That way, you just use the lightweight formula whenever you can, and you use the LotusScript agent when you have to. The button will set the Foo field if the preview pane is closed, and it will set it if the preview pane is open as long as there's only one document selected.

This page has been accessed 908 times. .
Comments :v

1. Patrick M08/07/2006 08:47:46 AM


Man, did I have a hard time figuring that one out a few years ago. This particular user had the preview pane open by 2-3 pixels, tops. It only dawned on me the day the pane was open a bit more.

Can you say Duh! moment? I knew you could.




2. edge08/22/2006 11:57:59 AM


Just correct one of the formulas either make isDocOpen "Yes" instead of "Y" or evaluate for the value of isDocOpen as being "Y" instead of "Yes". Anyway thanks for a nice little article that will help people me included!.




3. Richard Schwartz08/22/2006 12:11:54 PM
Homepage: http://www.rhs.com/poweroftheschwartz


Thanks for that correction!




4. Kenneth Axi03/23/2011 05:36:02 AM


Why this complicated workaround? Why not simply use @SetField instead of FIELD? It works regardless of the preview pane and You don't need a dummy field ("isDocOpen") etc... The code gets clear and You don't need any If-statements or LotusScript code or whatever...




5. vesoftware11/05/2013 10:17:43 PM
Homepage: http://vesoftware.blogspot.com/2013/10/itupokercom-agen-poker-online-indonesia.html


Agen Bola Promo 100% SBOBET IBCBET Casino Poker Tangkas Online
http://vesoftware.blogspot.com/2013/10/agen-bola-promo-100-sbobet-ibcbet.html
ITUPOKER.COM AGEN POKER ONLINE INDONESIA TERPERCAYA
http://vesoftware.blogspot.com/2013/10/itupokercom-agen-poker-online-indonesia.html
alfaonline.com : Toko belanja online murah, Promo heboh jual barang hanya Rp 1,-
http://vesoftware.blogspot.com/2013/10/alfaonlinecom-toko-belanja-online-murah.html
BELAJAR SEO
http://balapseo.blogspot.com/




6. online_cialis09/14/2016 06:49:00 AM
Homepage: http://c5sale.com/



http://c5sale.com/ ,




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-x :cry: :laugh: :-( :cool: :huh: :-) :angry: :-D ;-) :-p :grin: :rolleyes: :-\ :emb: :lips: :-o
bold italic underline Strikethrough





Remember me    

Monthly Archive
Responses Elsewhere



About The Schwartz

rss.jpg


All opinions expressed here are my own, and do not represent positions of my employer.