Getting the name of the current view

Hi,

Here is the scenario. I have number of views in my database and all these views have a button on it like “Create Request”. This button is supposed to compose a document using a form.

On the form, there is a “Save & Send” button. This button saves the document and sends email along with a .ndl attachment to the users MS Outlook inbox.

In the “Send email” agent for creating .ndl attachment, I have to create a ViewLink, so I put a view name in there, but for some users who use terminal servers, unless they create the new request from the same view (as in the send email agent), they cannot launch the ndl attachment from outlook to open the request they created in this Lotus notes database.

Example: The “Send email” agent gets executed when the “Save & Send” button is pushed. The agent has, for example, “View1” hard coded in it, the users who use terminal servers have to create new requests only from this view and not from any other views for the ndl attachments to work correctly.

Now my question is, I want them to be able to use any view and still the ndl attachment should work correctly. So, in the agent for sending email , instead of the view name hard coded, I want the code to figure out the name of the View from where a particular request was created.

I read about globals on the form, but I am not sure how to use it. I wrote the following code for getting currentview name, but I don’t know how to pass the view name value to a hidden field on the form. I want to pass the view value to a hidden field on the form and then to the send email agent. I don’t how to do that though, since I don’t know how to pass the value of the Current view into the hidden field. I tried putting the code in the querysave event, but it doesn’t work.

Dim wks As New NotesUIWorkspace

Dim uiview As NotesUIView

Dim doc As Notesdocument

Dim uidoc As NotesUIDocument

Set uidoc = wks.CurrentDocument

Set uiview = wks.CurrentView

viewName$ = uiview.ViewName

Any help is appreciated.

Thank you,

Archana

Subject: Getting the name of the current view.

Archana,

you are very close with what you have. Once you get a handle on the viewName, just do this:

set doc = uidoc.Document

doc.HiddenField = viewName

that’s all you need to do. Then when you go to save it or whatever, you can re-reference doc.HiddenField to know which field you are accessing.

hth.

brandt

Subject: RE: Getting the name of the current view.

Brandt,

I am sorry, but there is a mistake in my post. I have the code in the “QueryOpen” event , not QuerySave. In queryevent you cannot assign a value to a field since it’s not in edit mode. If I put the code in “PostOpen” however, the uiview is blank because now it is already in post open stage of the document and the “Workspace.CurrentView” is no longer valid there. This is the main reason, I am not able to figure out a way to pass the value to the hidden field.

Thank you for your help though.

Subject: RE: Getting the name of the current view.

Sorry for the late reply, but I just came across this while working through an issue I was having.

I had a similar situation and your comments helped me solve my issue. In QueryOpen I used the still valid Workspace.CurrentView to get the view name and saved it in a Global Variable on my form. I then used the value stored in the Global Variable later on in my form’s processing (a Save and Close button in my case).

Subject: RE: Getting the name of the current view.

Archana,

You may not be able to set a value to a field in the front end, but you can get a handle on the uidocument (via the Source) variable and you can set it equal to the backend document via uidoc.Document. Once you have a handle on that document you CAN set the value of a field since a backend document does not have an editmode and the field you want to pass the value to is hidden anyway and won’t be effected by the ui.

Brandt