I am trying to clean up some code from a previous developer.
The code is in a button within a form. When pressed it prints multiple pages using multiple forms.
The old code uses FileOpenDatabase to change views/forms. Then close the workspace, at the end it closes the document and reopens the original workspace.
The problem with this is that it rearranges the order of tabs for the docs and the workspace. This is confusing to the users.
I thought I found the solution in the SwitchForm command, but when it is activated it crashes Notes. It does this on any computer. They are running 6.5 on Win2000.
I can not use FilePrint to change the Form ecause it is being activated from within the Form.
What is the best way to approach this and has anyone else experiences problems with SwitchForm in Notes 6.5?
Here is a snippet of the latest code I have tried, it prints the first document (the one that is already opened), then crashes:
@If(@Text(Counter)!=“1”;@Do(
@Command([FilePrint] ; “1” ; “1” ;“1”;“”;“”;“Work Order”);
@command([filesave]);
@Command([RefreshHideFormulas]);
@Command( [SwitchForm] ; “Packing List” );
@Command([FilePrint] ; “2” ; “1” ;“1”;“”;“”;“Packing List”);
@Command( [SwitchForm] ; “Work Order” );
@Return(0));“”);
Thank you~
Subject: SwitchForm crashes Notes – is there a better way?
-
Use Lotusscript instead.2. Create a document in memory using notesdatabase.createdocument. Call this document1.
-
Create a rich text item in document1.
-
Create another document in memory, call this document2.
-
Put a rich text field on document2.
-
Change the current document’s form to WorkOrder.
-
Call document.rendertortitem( document2.Body ).
-
Append document2.Body to document 1’s body.
-
Remove the Body field from document2
Repeat steps 6-9 for all the other ‘printing’ versions of the form.
Subject: RE: SwitchForm crashes Notes – is there a better way?
Thank you for your response. I have considered using LS but have decided not to at this point. My reasoning is: the formulas behind this button is quite extensive, and there are numerous different forms to be printed (more than in the code snippet I included).
I’m afraid that it’s hard to justify the overhead in rewriting all the formula language to LS for this one task.
I have been playing around with many variations of the formulas but still can not quite get it to do what I want.
I suppose I’[m still holding on the the belief that this can be done with the formula language.
If the SwitchForm command didn’t crash for me, would that do what I needed?
Thanks again.
Subject: RE: SwitchForm crashes Notes – is there a better way?
hmmm…I would be leary of saving and resaving a document just to print it.
Guess … what about changing the Form field and using @Command( [ViewRefreshFields] ) or @Command( [RefreshWindow] ) . Seems doable without saving, but I haven’t tested it.
Subject: RE: SwitchForm crashes Notes – is there a better way?
Yes, that’s the point of using script, you don’t have to save the document and you don’t have to trust that the all the various ui stuff (opening and closing the document etc) plays nice with the printing. That’s a formula I would drop like a bad habit.
Subject: RE: SwitchForm crashes Notes – is there a better way?
After many variations of failed attempt to do this with the formula language I feel that I must give in now and rewrite many lines to LS if I want to achieve my goal.
Thank you for your help~