Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a button thanks links to a subform

Status
Not open for further replies.

R1Yamaha

IS-IT--Management
Nov 22, 2005
7
US
Hi all...Thanks so much for the tips on my previous question. Here is a tricky one for me. I am adding a button to the default inbox template. I would like this button to link to our "Company name and address book by last name" and goto the subform $UserprofileInfo. We would like this section to be filled out by each employee and would like to make navigation to this easy. Is there a formula that I can use to lookup the document and open it for editing. I created another form that will execute when that button is clicked and wanted to use the embbedded editor feature to edit that info and update the name and address book on the server. I am just having trouble with the lookup portion so it opens the correct document for that user. can anyone help with this. thanks
 
didn't mean to say subform....the embedded editor will access a subform but i need it to select the current users subform.
 
The easiest is probably to write a little LotusScript for this, formula language can do the trick, but since you need an external document returned it becomes slightly more complex; Doable, but probably not worth the effort...

So a code something like this could do the job, some small modifications might be needed...

(On click sub)
...
Dim session as new NotesSession 'To get the username
Dim workspace as New NotesUIWorkspace
Dim UName as New NotesName(session.Username)
Const ViewName = "($Users)"
Const NABName = "names.nsf"
Dim userdoc as NotesDocument
Dim db as New NotesDatabase(workspace.CurrentDatabase.Database.Server, NABName$)
' To find public address books can be done more elegant...
If (Not (db.IsOpen)) then
Call db.Open("", "")
if (Not (db.IsOpen()) then Exit Sub
End if
Set userdoc = db.getView(ViewName).GetDocumentByKey(UName.Canonical, True)
if (Not (Userdoc is nothing)) then
workspace.DialogBox("<Yoursubform>", True, True, False, True, False, False, "User info update", userdoc, True, False, True)
' Different options can of course be set in DialogBox, also depending on the subforms design...
end if
...

Not tested, of course, but should not be too far from the target. When using a dialogbox you will update your info through your defined subform as a 'proxy', and when clicking Ok it is stored in the NAB if the user have the rights to do so. That is sometimes the biggest challenge, so make sure the users actually can update these fields in the NAB...



Brgds,

TrooDOS
 
Thanks alot. I will try it...Basically this is the corporate address book i am trying to open and users all have rights to edit their own personal data (hence the subform) not any server/client data..ie name shortname..etc

I will let you know how i make out...thanks so much
 
Troodus...Hope you had a happy new year.

This is not working for me...I get an error about illegal parenthesis....Also I am not sure what exactly needs to be done on my side.

I created an action button....I want that button to open the subform $PersonGeneralInfo ..this will be unique for each user. Is there an easy way to have the button lookup the user info and open the appropriate document from names.nsf. Eash user has the ability to edit this section in the names and address book. Maybe I am just not understanding what is going on in the backround. So please elaborate a little for me...There is nothing special in our names.nsf db. It is a standard Address book so I believe if needed you can test on your side with your names and address book to see what is happening on my end. Thanks so much for the support
 
Try to put in 'Call' in front of the line 'workspace.Dialogbox(...' first, or use an 'IF' to check the reply from the box...

Try to use this:
...
Call workspace.DialogBox("$PersonGeneralInfo", True, True, False, True, False, False, "User info update", userdoc, True, False, True)
...
or this:
if (workspace.DialogBox("$PersonGeneralInfo", True, True, False, True, False, False, "User info update", userdoc, True, False, True) = true) then
...

As said before, it has not been TESTED by me, but the paranthesis message is typical when a CALL statement is missing in front when there is more than 1 parameter in the statement...

Try it and see. It can still be some minor errors of course, but I think it would be syntax OR maybe object related...



Brgds,

TrooDOS
 
lol....okay i used that code and it opens my latest mail document....the $PersonalGeneralInfo is located in the names.nsf


Where in this code is it making a call to names.nsf and opening the users $PersonalGeneralInfo subform in names.nsf? maybe that's where i am lost...

Thanks for all your effort and continued help with this.
 
Ok, the physical location of the subform complicates things... The code was basically written for an existing subform from the calling database, and the extract only the document from the Domino Directory, edit it and save it BACK to the DomDir...

The opening of the database is these lines:
Dim db as New NotesDatabase(workspace.CurrentDatabase.Database.Server, NABName$)
' Check if it has been opened. If not, try to open it. If it fails again, exit the SUB
If (Not (db.IsOpen)) then
Call db.Open("", "")
if (Not (db.IsOpen()) then Exit Sub
End if
' Then find and open the current users document
Set userdoc = db.getView(ViewName).GetDocumentByKey(UName.Canonical, True)
if (Not (Userdoc is nothing)) then
...

Since your form is inside the Domino Directory, the next lines call will fail since your are INSIDE your maildb, and the subforms not available within this DB.

The 'FORMS' method will give access to the NotesForm class, or use the database method db.GetForm("<FormName>"), BUT this returns a NotesForm class, and can not be used in the dialogbox directly... It would have been ideal IF it could be COPIED from one database to another in the background (and removed again after use), but there are no available methods for this in default NotesDatabase, NotesDocument or NotesForm.

For access to the whole MAIN person form the following UI method can be used:
Set notesUIDocument = notesUIWorkspace.EditDocument( [editMode] , [notesDocument] , [notesDocumentReadOnly] , [documentAnchor$] , [returnNotesUIDocument] , [newInstance] )
BUT this will only open with the specified/stored form, so if this is a person document, the PERSON form will come up, no subform...

If you are using a TEMPLATE on mail databases (or where you trigger the button) you COULD have copied and added in the subform there, this WOULD probably be easiest, since there is no CREATEFORM or COPYFORM methods available in LotusScript. There is in the formula language, but that creates only an empty form.

So for remote use of external subforms it becomes a bit 'iffy'. One THEORETICAL alternative is to OPEN the NAMES.NSF and THEN trigger the subform, but there is a lot of potential pitfalls there.

Sorry...


Brgds,

TrooDOS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top