Link to home
Start Free TrialLog in
Avatar of DrTrollrot
DrTrollrotFlag for Sweden

asked on

@Command([OpenView])

Ok, i have 2 databases, Database A and B

Database A is filled with documents that have files attached to them

What i want to do is, the user press a button in database B and that will open a document in database A. I have played around with some code and i can get it to work, but it only opens the first or the last selected document.
@Command([ToolsRunMacro];"OpenExport");
@Command([FileOpenDatabase]; "Server":"DIR\\database.nsf"; "myVew";"DocumentInView" ;"1"; "1" )
@Command([EditDocument];"1");
@Command([EditGotoField];"vAttachment");
@Command([EditSelectAll]);
@Command([AttachmentLaunch]);
@Command([EditDocument];"0");
@Command( [FileCloseWindow]);
@Command( [FileCloseWindow])
 
I have also tried
 
@Command([ToolsRunMacro];"OpenExport");
@Command([FileOpenDatabase]; "Server":"DIR\\database.nsf"; "";"" ;"1"; "1" )
@Command([OpenView];"myVew";""DocumentInView");
@Command([OpenDocument]; "1")

Open in new window

Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Is there any relation between the documents in A and B? How do you know what document you want to open in A?

Apparently you don't want to open the document, but you intend to launch the attachment in there. There are better ways to get that done. How many attachments are there in the document?
Avatar of DrTrollrot

ASKER

By the button in Database B i control what document i want to open in Database A (a lot of buttons in the end :)

This is why i tried ..
@Command([FileOpenDatabase]; "Server":"DIR\\database.nsf"; "myVew";"OpenDocumentInView" ;"1"; "1" )

And back to your question, only the attached file in the specified document is important, and it will only be one attached file in each document.

I have successfully done this but only if there is one document in Database A, when i add more it stops to work.
Okay, so there's no relation? Or do you have 10 buttons, each numbered from 1 to 10 or so, and when the user clicks button 5 you want the 5th document to be opened? You'd better get the IDs of those documents through a DbColumn or DbLookup, so you can directly address the right document.
Database B
Action Button "Technical Manual"
Code if it worked with more than one docment.
@Command([FileOpenDatabase]; "MyServer":"docdatabase.nsf"; "Technical";"TechManual" ;"1"; "1" )

@Command([EditDocument];"1");
@Command([EditGotoField];"vAttachment");
@Command([EditSelectAll]);
@Command([AttachmentLaunch]);

So explained ... This launch docdatabase.nsf, it will go to the view "Technical" and it should select the document "TechManual" in Database A. It will then open the document in edit mode, go to the attachment field, select it and launch it.

The relation should be the file i specifed in the Action Button compared to the name of the document in the first column in Database A.

So if i write Cheese in the action it will open database A, go to the specified view and look for the document "cheese" and open it.
I think it's more appropriate to use LotusScript here...
ASKER CERTIFIED SOLUTION
Avatar of DrTrollrot
DrTrollrot
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forget the code you use, you're on the wrong track. It can be done in Formula, but NOT by opening views etc. It even think that Formula is easier, for I wouldn't know how to launch the application for the attachment from LotusScript. Must be doable, I think...

Anyway, you can locate a document in a different database using @DbLookup. You can then open that document and start the attachment.

It is also possible to start the first attachment by using a different form. The form's launch properties should be set to "Start the first attachment"
Well... sorted, yes, of course... I assumed the view was sorted...

IMHO the code is still not very elegant, and I doubt it is fool-proof. For instance, your code won't work if someone doesn't have editor rights on the document.

You're too fast in closing the question...
True, it wont work if the user dont have edit rights nor will any error message pop-up if the user dosent have the software installed to open the attached file. But as for the moment the solution above will be sufficient.

I might add that if you place the code directly under a Action Bar button you will get an error, the solution for that is to put the code in a agent and call it by @Command([ToolsRunMacro];"YourAgent");