Hiding Action Buttons

Is it possible to hide one or more of a view’s action buttons only when the view is embedded (on a form)? If so, how?

Subject: Hiding Action Buttons

you can hide the entire action bar but I don’t think there is a way to pick and choose which button to show/hide. To hide the action bar go to the form on which the view is embedded and right click the embedded view element. I think it’s on the second tab and there is a check box to “Show Action Bar”, just deselect this. Hope this helps.

Subject: RE: Hiding Action Buttons

Thanks Paul. I need to show some buttons but hide others when embedded. I’m thinking that I’ll just have to create another view.

Subject: RE: Hiding Action Buttons

Well, it IS possible, but my solution is not exactly elegant.

The idea:

In the view’s PostOpen, try to retrieve a NotesUIDocument object. If it does exist, were inside an embedding form. In this case, set a field in a user specific profile document, that determines what actions to hide. In each action’s hide-when-formula, check for the values in the flag field and hide the action if appropriate. Since we are in PostOpen already, finally refresh the hide-when-formulas …

The challenge:

Actually a couple of them, but mostly how to refresh the hide-when-formulas.

The solution:

Create a profile form (not required, but handy for manual editing and checking) e.g. UserProfile, with a multi-value field ActionsToHide.

In the view’s global declarations we will need:

Dim uiws As NotesUIWorkspace

Dim sNotes As NotesSession

Dim db As NotesDatabase

Dim uidoc As NotesUIDocument

Dim userName As String

Dim docUserProfile As NotesDocument

In the view’s global initialize we can get our basic entry classes and retrieve the profile document:

Set uiws = New NotesUIWorkspace

Set sNotes = New NotesSession

Set db = sNotes.CurrentDatabase

userName = sNotes.UserName

Set docUserProfile = db.GetProfileDocument("UserProfile", userName)

Not before the view’s PostOpen can we try to retrieve a NoteUIDocument object. If it does exist, we fill the field ActionsToHide and save the profile:

Set uidoc = uiws.CurrentDocument

If (Not uidoc Is Nothing) Then

	Dim actionsToHide(0) As String

	actionsToHide(0) = "CountUnprocessed"

	Call docUserProfile.ReplaceItemValue("ActionsToHide", actionsToHide)

	Call docUserProfile.Save(True, False)

	Call uiws.ViewRefresh()

End If

I added only one identifier here, CountUnprocessed. The name itself doesn’t have to match the action’s name, in fact it doesn’t have to have any meaning at all. This is just the string we will ask for in the action’s hide-when-formula. But before creating the hide-when-formula, we will populate the view’s QueryClose event with some code, to delete the contents of the field ActionsToHide, so the view will show with all actions the next time it is opened outside of the form:

If (Not docUserProfile Is Nothing) Then

	Call docUserProfile.ReplaceItemValue("ActionsToHide", "")

	Call docUserProfile.Save(True, False)

End If

The hide-when-formula for the action(s) is simple enough, in this case:

@If(

@GetProfileField(“UserProfile”; “ActionsToHide”; @UserName) *= “CountUnprocessed”;

@True;

@False

)

So, are we done now? No. Unfortunately this still doesn’t work. the hide-when-formulas will not update, unless we actually select the embedded view and press [Shift]+[F9]. So, we’re toast and this simply doesn’t work.

Not quite. Since we were blessed with the most underrated Notes release ever, there is a way around it: In the view properties, second tab, check the box to “Evaluate actions for every document change”. It wasn’t really intended for this use, but it does the trick: The action’s hide-when-formulas are re-evaluated every time “something happens” in the front-end. And that’s all we’ve been asking for.

The drawbacks:

The option to evaluate actions for every document change slows the view down. Don’t use it on views with thousands and thousands of docs.

We have quite a bit of code to write just to hide actions selectively. Simply creating a second view might be easier (once you migrate to 7 or 8, shared columns would make this approach even more tempting).

As is, the information about which actions to hide is within the code. One could place it in configuration documents and only keep an on-off flag field in the profile. The most obvious solution might be, to keep this info in the profile doc permanently, and just use the on-off flag field along with it. This has one disadvantage: The profile document has to exist before using it. GetProfileDocument will create a new profile document, if none exists yet, it will however not fill any fields based on default or computation values. ComputeWithForm will not work, also.

O.K., is this of any real practical use? I don’t know. But it was a little fun and now I’m tired enough to go to sleep.

Subject: RE: Hiding Action Buttons

After sleeping over this, and discussing the idea with a colleague, it might even be possible to simply store the list of actions to hide in a hidden field on the embedding form. Would save the hassle with a profile document, save the whole QueryClose code, perform no worse and be more robust with respect to people opening the view and the form at the same time.

SaveOptions should be set to “0” on the embedding form anyway …

Subject: RE: Hiding Action Buttons

Well done and thanks Harkpabst! I haven’t tried it yet but I can’t see why it won’t work.

Subject: RE: Hiding Action Buttons

I thnk you can improve on Harkpabst’s solution a bit. Try setting the profile field in the outside document’s QueryOpen, then just use a hide-when in the view’s action button. See this: http://tinyurl.com/2emfww