Link to home
Start Free TrialLog in
Avatar of PaulCutcliffe
PaulCutcliffeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

I need to print some Documents from LotusScript using alternative forms - can this be done?

I have developed an order management system using Lotus Notes/Domino R7.0.1, & have been asked to provide a button that prints out a load of Documents of a certain status. When discussing these changes with the client, I didn't foresee a problem, but looking at the documentation, it seems to me that LotusScript is not over endowed with printing functionality, to say the least.

I expected to have no way of selecting a printer or changing the default printer, and I wasn't disappointed there, but I was expecting that I could either open or print a Document using an alternative Form, but neither NotesUIWorkspace.EditDocument() nor NotesUIDocument.Print() take an argument for an alternative Form. Never mind, I thought, I'll just get a NotesUIDocument from a NotesDocument from a View with a Form Formula set, but having tried this, it just completely ignores the Form Formula, using the 'normal' Form instead.

I've always thought it a really powerful feature of Notes that it can display Documents using alternative Forms, but what good is it if you can't print them out?

Do I really have to edit each Document, change the Form Field to the Form I want to print using, print the Document, then change the Form Field back again? Is there really no better way to do this? This would be a horrid solution - what if the Agent doesn't complete? Then you'll be left with some Documents that have the Form field set incorrectly, which would probably mean they wouldn't even appear in the right Views!

Just before posting this question, I've just found NotesUIView.Print(), which does have a formOverride parameter, so maybe I can use this? I guess I'd have to create a Folder (which from LotusScript's perpective is the same as a View), add the various documents I want printed to this Folder, then issue a UI Select All command, then use the NotesUIView.Print() method specifying the alternative form as one of the parameters, then finally remove all the Documents from the Folder. Whilst this might actually work, all this is going to happen on the screen & seems a bit messy - can anyone think of a better idea, or even confirm whether this idea will work?

Any thoughts or comments gratefully received.
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

I can only offer my standard panacea for printing things from Script: www.notestopaper.com But probably you don't want 3rd party products, or you don't want to pay for them, or they are too expensive... By the way, there are other, similar products (e.g. Midas), but I used NotesToPaper and I know it works. Say hi to Peter Hoffmann from me when you contact them ;-)
Avatar of PaulCutcliffe

ASKER

sjef bosman: As you suspected, using third party software isn't an option for this Agent.

SysExpert: Interesting reading, but not really applicable here.

I will pursue the Folder/NotesUIView.Print() idea I outlined in my original question & report progress back here - please feel free to comment/contribute...
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France 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
Actually, qwaletee's solution was quite useful - I may see if I can incorporate some of this ideas.

Watch this space...
I'm all eyes!!!
Well the NotesUIView idea is out the window, as I've just realised you can't get hold of a NotesUIView unless the user opens it themselves.

The documentation provides two examples - one shows code in one of the View UI Events, & the other uses NotesUIWorkspace.CurrentView.

So I'm going to use an idea seen in qwaletee's solution where the form field of the open NotesUIDocument is changed just before printing.
Got it! When I open the Document, I open it in Read mode with the ReadOnly flag set, so I can't edit it once it's open. In fact I couldn't anyway, as Form is not an editable field.

However, I've found that if I change the on the backend Document just before opening it, even if I don't save it, it opens using the correct form.

For example:

Dim ws as New NoteseUIWorkspace, docOrderItem as NotesDocument, uiDoc as NotesUIDocument
docOrderItem.Form = "Job Sheet"
Set uiDoc = ws.EditDocument(False, docOrderItem, True, , True, True)
Call uiDoc.Print(1)
Call uiDoc.Close(True)

This opens the OrderItem document using the Job Sheet Form, prints it then closes it.

Job done!

sjef_bosman: I'll award you the points, as you pointed me towards qwaletee's solution, which led me to try this way of doing it, so thanks for your help (again).
I've just had another look at qwaletee's solution, & it really is quite elegant - I tend to only think in terms of LotusScript, & as this was never the 'native' way of doing things in Notes, it always seems awkward, almost as if LotusScript has been added to Lotus Notes as a bit of an afterthought - oh yeah, it actually was! :-)

So much of our time as Notes developers seems to be spent trying to get around the limitations of what you can & can't do easily in Notes! And yet we take so many things for granted that it does do really easily.
I agree with you for 100% !

Thanks!