Solved

Lotusscript - Insert Subform into a Form

Posted on 2011-09-30
6
1,755 Views
Last Modified: 2013-12-18
Dear Experts

I'm sure this question been asked before, and seriously tried serching before posting a question.

We're using Lotus Notes 8.5, is there a way to insert a Subform via Lotusscript ? If yes, can I get a guidance on how to do it ? Many thanks in advance.
0
Comment
Question by:Faraj1969
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:cohalex
ID: 36891017
You can use a computed subform (insert from Create\Resource\Embed subform from teh Designer menu) on your main form.
Put the name of a field as value for your subform name.
Use LS to change the field value.

 computed subform
0
 

Author Comment

by:Faraj1969
ID: 36891086
OK, seems there's a way, so let me explain it better.

I'm opening a Form through dialogbox, the form should give me a chance to enable/disable sections and to decide if access to the section should be Edit or Read. I created a subform for a single section. When user click on a button, the dialogbox appear and in PostOpen event, it will check how many sections available in database (it's known at runtime, not before) and the PostOpen event will add the subform for every section available. Hope my explanation is clear. Let me know please.
0
 
LVL 4

Expert Comment

by:cohalex
ID: 36891173
This is perfectly doable and is a practice in many Notes applications.

Before calling the dialog box to open a given document, you should compute the accesses and set one or more fields in the document to reflect flags for showing / hiding sections and / or computing the subform names. Of course, you will save the document with those flag fields before launching it in the dialog box window.

In your scenario, when the user clicks the button - inside the button script:
- get or compute the accesses
- set flag fields accordingly
- save the document
- call open document in dialog box with a single form

If you want, you can also reset those flag fields on the QueryClose form event, so that after the dialog box window is closed, your doc is the same.

To make it easier for your testing, create those flag fields as visible and editable, play with them, and open close the document if needed to have the refresh (no need for dialog box yet).
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:Faraj1969
ID: 36891347
The solution sounds encouraging, but I'm a bit confused. A key factor here that number of sections is unknown. When the main form opens, on PostOpen event, it will check how many sections available, and add as much subforms, for example, the main form opened and found 5 sections in view, so it inserts 5 subforms then it's being presented to user for modifications. The main form will not be saved, just the data will be extracted and saved elsewhere.
0
 
LVL 4

Accepted Solution

by:
cohalex earned 500 total points
ID: 36891597
There are two things here:
- you can use computed subforms to dynamically load the desired subform
- you can have a hide-when formula on the text property of your (computed) subform

Keep in mind that hidden subforms still evaluete all the events and fields contained - they are just not visible, unlike a computed subform that evaluates the subform name to null, where it's like the subform was never added to the main form.

You will need to add all subforms on your form - this is a must.
You will then show / hide only those that are allowed for the current opening.

You will not need any action on the form PostOpen event - the subforms will display correctly based on the hide when formulas.

Hope it's a bit more clear.


And another tip: if you don't want to use flag fields and perform a save on the document, you could move those flag fields in a user profile document - they are special documents which are always loaded in the memory of the user's notes client and easily accessible from both LS and FL.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 36899152
AFAIK, subforms are loaded when the whole form is loaded, so you cannot select a different subform once the form is loaded. You'd have to save the selected subform (name) somewhere and then reopen the document to display the document with the selected subforms.

I could be wrong though...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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