Avatar of Michael Purdham
Michael Purdham
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Compose a new document opening the form in a window and control the window size?

I have a simple form that is composed from a button on another form.

It only contains a few fields, some inherited from the main form and looks rubbish when launched full screen in the client.
Is there a way of launching this in a window and controlling the window size?

I cannot use @Dialogbox as the values are not returned to the main form, I need to create a new document each time.

Thanks.
GroupwareDatabases

Avatar of undefined
Last Comment
Michael Purdham

8/22/2022 - Mon
Sjef Bosman

Of course you can use @DialogBox! Maybe not in Formula language, but surely the equivalent in LotusScript.

In pseudo-code, in the button's Click code:

     create a temp. NotesDocument
     fill some fields from the main document
     call ws.DialogBox with this temp.document
     if OK then save the temp document (or copy its values to a new document)
Michael Purdham

ASKER
Thanks Sjef. LotusScript is where I usually come unstuck. In my comfort zone with formula language.

At present in LS I have this as I found the reference to width and height but apparently not supported anymore.

Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Call workspace.ComposeDocument( "", "", "Comment")
End Sub

How would I do what you suggest?

Thanks
ASKER CERTIFIED SOLUTION
Sjef Bosman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Michael Purdham

ASKER
You are right, I should learn more LS. I used to have a guy who was fluent but v. sadly had to let him go.

I get  the error on line 4 'Type mismatch on db'

Sub Click(Source As Button)
      Set ns= New NotesSession
      Set db= ns.Currentdatabase
      Set tmpdoc= New NotesDocument (db)
        ' you can fill tmpdoc fields if you want, with values to be used on the form
      If ws.Dialogbox("Comment", True, True, False, False, False, False, "Create abc", tmpdoc, True) Then
        ' use the values in tmpdoc in some other document            
      End If
End Sub


Thank you for your patience.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Sjef Bosman

Ah, well...

Better enable an option in the Designer Preferences: automatically include 'Option Declare', so you must declare all variables.
To be added, after the Sub Click:
    Dim ns As NotesSession
    Dim db As NotesDatabase
    Dim tmpdoc As NotesDocument

Open in new window

Michael Purdham

ASKER
This now works, thanks

Sub Click(Source As Button)
      Dim ns As NotesSession
      Dim db As NotesDatabase
      Dim tmpdoc As NotesDocument
      Set ns= New NotesSession
      Set db= ns.Currentdatabase
      Set tmpdoc= New NotesDocument (db)
      Set ws = New NotesUIWorkspace
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
      ' Fill tmpdoc fields with values from the document
      tmpdoc.CoUNID = doc.CoUNID
      tmpdoc.CoName = doc.CoName
      tmpdoc.ConUNID = doc.ConUNID
      tmpdoc.SourceForm = doc.Form
      'Resizes the window to fit the table on the form
      If ws.Dialogbox("Comment2", True, True, False, False, False, False, "Create new Comment", tmpdoc, True) Then
      End If
End Sub
      'Button on the form saves the doc
Michael Purdham

ASKER
Thanks for your patience
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Sjef Bosman

> Button on the form saves the doc...
Do you save tmpdoc in the form? Better not do that, better return OK and save the form from the script code above. A DialogBox shows data using a form, but does not everything a form does. For example, it doesn't add a field $ConflictAction, even if the form tells Notes what to do in case of a replication or save conflict. Likewise, if you specified in the form that the documents are supposed to be Response to Response, nothing happens.

Test carefully, that's all I intended to say...
Michael Purdham

ASKER
Point taken. Reverting to type and using Formulas. My Save button also checks for a value in the Comment field and prompts the user.

I agree it would be neater to use the OK/Cancel rather than an additional button

I would expect that following the addition of

Call tmpdoc.save (True, False)

that clicking OK that would save the document.
It doesn't.

How do I validate the Comment filed and Save the doc using the OK button?
Thanks
Sjef Bosman

Sorry, have to look that one up, I can't remember how I did it "back then". I'l be back in 12 hrs or so.
Or maybe someone else...?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Sjef Bosman

Ah, found it: when the user clicks OK, the return value in notesUIDocument.DialogBoxCanceled is False, when he clicked Cancel it's set to True. Please look up this property in the Designer Help database. Or see http://www.codestore.net/help/help85_designer.nsf/b3266a3c17f9bb7085256b870069c0a9/4fcd5d7fae9b444c852574cf006b9770?OpenDocument and find out how it's sopposed to be used (e.g. using the example).
Michael Purdham

ASKER
Many thanks for your help