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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
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 ;-)
PaulCutcliffeAuthor Commented:
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...
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Sjef BosmanGroupware ConsultantCommented:
I "know" CRAK had a solution to this problem, but I have yet to find it.  It could have been this one: http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/Lotus_SmartSuite/Lotus_Notes/Q_21245371.html but I'm not sure...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PaulCutcliffeAuthor Commented:
Actually, qwaletee's solution was quite useful - I may see if I can incorporate some of this ideas.

Watch this space...
Sjef BosmanGroupware ConsultantCommented:
I'm all eyes!!!
PaulCutcliffeAuthor Commented:
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.
PaulCutcliffeAuthor Commented:
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).
PaulCutcliffeAuthor Commented:
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.
Sjef BosmanGroupware ConsultantCommented:
I agree with you for 100% !

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.