Solved

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

Posted on 2014-01-06
12
327 Views
Last Modified: 2014-01-09
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.
0
Comment
Question by:kcoxon
  • 6
  • 6
12 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39759063
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)
0
 

Author Comment

by:kcoxon
ID: 39759080
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
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 500 total points
ID: 39759130
That's years ago... ;-)
And I think it's about time you get acquainted with the wonders of LotusScript programming. No more excuses in 2014!

	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("SmallForm", True, True, False, False, False, False, "Create abc", tmpdoc, True) Then
            ' use the values in tmpdoc in some other document		
	End If 

Open in new window

0
 

Author Comment

by:kcoxon
ID: 39759187
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.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39759261
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

0
 

Author Comment

by:kcoxon
ID: 39759512
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
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Closing Comment

by:kcoxon
ID: 39759518
Thanks for your patience
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39759599
> 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...
0
 

Author Comment

by:kcoxon
ID: 39759680
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
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39760754
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...?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 39763340
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).
0
 

Author Comment

by:kcoxon
ID: 39767724
Many thanks for your help
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now