?
Solved

Adding Subform based on Script instruction

Posted on 2005-04-20
31
Medium Priority
?
850 Views
Last Modified: 2013-12-18
Hi everyone

I know how to add a subform based on a formula, but how we can do it through Lotus Script ?

Regards
0
Comment
Question by:Faraj1969
  • 12
  • 8
  • 8
  • +1
30 Comments
 
LVL 13

Expert Comment

by:CRAK
ID: 13822693
Never tried it, but you could write a field to the document and compute the subform based on its value or use an environment variable instead of a field.
You probaply need to do so in queryopen.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13823773
I don't think this is possible. Even the subforms are loaded before the QueryOpen is fired.

My two cents...
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 13826204
Sjef, I don't think that's right, QueryOpen executes before any rendering, and subforms are part of rendering.  You should be able to use QueryOpen to modify Source.Document.SomeFieldWhereYouPutTheNameOfTheSubform and then have the subform compute to SomeFieldWhereYouPutTheNameOfTheSubform

Note sure if you need to have a field on the form named SomeFieldWhereYouPutTheNameOfTheSubform
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13826414
I'll test this tomorrow, if I haven't already been proven wrong... ;-)
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13828352
If you do, you might want to consider a shorter fieldname: a typo in "SomeFieldWhereYouPutTheNameOfTheSubform" might get you stuck with scientifically unreliable results!
(A freebie!)
;-))
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 13835744
You have issues with 39-character identifiers?  Puny human.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13837648
Not really.... some of my friends have "identifiers" that long. But we often refer to to each other by shorter aliases. E.g. in the hockey rink those short identifiers provide a lot of ease when addressing team mates after a failure to score or unneccessarily losing the ball to an opponent. Pitty the membership agreement doesn't allow me to give an example. I'm sure you'd understand!
Some people have a troublesome "keybaord" though.... the longer the identifier gets, the higher the change on error.

A long as there are electronic devices involved, human error is never the issue!
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13837678
How are you doing Faraj1969? Is there a light at the end of the tunnel yet or are you still groping in the dark?
0
 

Author Comment

by:Faraj1969
ID: 13841246
lol... I'm still groping in the dark... I usualy wait for someone to hand me the trunk, and I'll pull the rest of the elephant. I'm working on it now, just trying to manage the coding.

To put more light on the elephant, before initiating the form, I have a DialogBox that have some questions like "YES, NO" or "SINGLE, MARRIED, DIVORCED, WIDOW" and so on, based on those questions, I just compose a form, and start adding subforms, then present the form to the user to fill in. This way, I avoid the user filling unnecessary information or printing empty forms.

Cheers
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13841548
Ok, here's a trunk....

I have created 3 subforms: SubA, SubB and SubC.
Each containing nothing but the letter A, B or C resp.

I created a form "LsComputedSub", containing a computed supform only. Formula: UseSub (this field doesn't really exist).

Then I added this agent (menu, run once):
Sub Initialize
      Dim WS As New NotesUIWorkspace
      Dim Session As New NotesSession
      Dim Db As NotesDatabase
      Dim Doc As NotesDocument
      Dim Choise As String
      
      Set Db = Session.CurrentDatabase
      Do
            Choise = Ucase$(Inputbox$("Enter subform (A, B or C)", "Choose subform"))
      Loop Until Choise Like "[ABC]"
      
      Set Doc = Db.CreateDocument
      Doc.Form = "LsComputedSub"
      Doc.UseSub = "Sub" & Choise
      
      Call WS.EditDocument(True, Doc)
End Sub
0
 

Author Comment

by:Faraj1969
ID: 13841674
Public Sub TestingPhase( CRAK_Code )

          MsgBox "Initiating testing procedure for CRAK_Code, Please wait..", MB_OK + MB_ICONINFORMATION, "Information"
          Call StandBy.Testing( CRAK_Code )

End Sub
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13841704
Sneaky! But can you do it from a QueryOpen, in the form itself?
0
 

Author Comment

by:Faraj1969
ID: 13848980
Thanks CRAK, it worked nicely, I just need to manipulate it a little and try to see if it works from QueryOpen.

Grateful everyone.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13849355
Faraj,

Please be back to confirm to me that it doesn't work from QueryOpen? ;)

Sjef
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13851435
I change the subform computation to:
@Environment("UseSub")

Then I dropped the agent and put this code in LsComputedSub's QueryOpen:
Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
      Dim Session As New NotesSession
      Dim Choise As String
      
      Do
            Choise = Ucase$(Inputbox$("Enter subform (A, B or C)", "Choose subform"))
      Loop Until Choise Like "[ABC]"
      
      Call Session.SetEnvironmentVar("UseSub", "Sub" & Choise)
End Sub

Like a charm, Sjef!


Faraj1969, what's with the B? Service doesn't often get as good as this!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13852978
With an environment variable? Yacky-bah!! One of those Notes 3 remnants... Should be banned.

Grade A for the pragmatic solution, but I'd given an E for the use of the neveroment var...

Sjef ;)
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13854961
Well, when I thought it over again..... if I'd write a field to an existing document, what would happen if 2 people decide to open the same document at the same time?
It has also served me well in the past when I had to fire a multi-step agent. I thing in the days when a dialogbox wasn't available in script.
I had to launch an agent to provide me the dialogbox, have it launch a 2nd agent running on a set of documents in a view or so and then launch a 3rd agent to perform another single task. The three had to exchange some variables. The only was appeared to be the use of an environment var.

I don't prefer the use of environment vars, but why condemn it in advance?

What are the other two remnants?
Do you think the features added later are perfect? I dislike pages (in web apps), I can't like outlines and frames don't offer me all I need (e.g. a JS library). It's about time they offered some documentation on the NotesCrash class too! It must be either top-level or embedded in both NotesSession and NotesUIWorkspace. It probably has optional arguments like NotesDateTime and a User- or ServerName. I know it's there somewhere, but I can't get hold of it....
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13856879
My objection towards environment vars is that they are just one building block too many. In Notes you can glue almost anything together, up to a point that the poor maintenance guy loses his marbles. In LS you can call Formula, I managed to "call" LS from Formula, with one agent you can start another, throw in some Java and JavaScript, some nice embedded HTML, and fix the holes with neveroment vars, not to forget C, C++ and external Java programs or Applets and VB or other COM stuff to complete the list.. To me, neveroment vars are some sort of last resort: if all else fails... Needs to be well-documented, but that must be done for almost everything in Notes.

Features of Notes? What about a better interface to UI e.g. to be able to do active frame control, and a bug-free NotesTimer?

I hope for you Faraj will reconsider his grading...
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13861813
> ...last resort.... if all else fails...

I fully agree! I also make exceptions when a workaround for its use makes it a lot harder to grasp or maintain the code. An environment var is abailable to any freshman. API's aren't.....
I had to! ;-)

Never mind the grading. Bing a PE I should have put that comment differently. I should have explained or pointed to http://www.experts-exchange.com/help.jsp#hi73.
For either of us this competition isn't about points, is it? Its the challenge.... the thought of helping someone struggling with a piece of code in a different part of the world.
0
 

Author Comment

by:Faraj1969
ID: 13875740
Hi everyone, I was just openning my email and found several comments were added here, specialy after I accepted CRAK answer.

Anyway, CRAK, I know ( A ) is a suitable grade for your solution, but I almost changed the whole solution to fit me, still working on it tho, but the idea was fantastic, at least I know its possible, and I'm very thankful for it. The only mistake I did was, that I wanted to increase the points to 100 at least, cause I can realize the code took alot of effort, but I forgot, and if EE gives a chance, I would do so.

And yes sjef, I'll be back to confirm wether it did work or it didn't...

Many thanks everyone.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13876147
Being a Page Editor, I could unaccept the question if you insist. But there's no real need to.
It wasn't that much effort....

But since to intend to become THE expert in LS computed subforms, perhaps you've figured out a solution for Sjef at http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21401754.html
;-))
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13876586
You'd make my day!  :-D
0
 

Author Comment

by:Faraj1969
ID: 13900956
Ok, with Environment variable, as CRAK suggested, it worked also, but would it work for 3 or 4 subforms ? thats one.

Second, is there anything in LS like NotesUIDocument.InsertSubForm( "SubformName" ) ?

I find this my only wall to break so far, and to be honest, I'm almost giving up and looking for better idea to do it.

Cheers
0
 

Author Comment

by:Faraj1969
ID: 13901104
I just tried to add 2 Computed Subforms, and I noticed registering the vars in Notes.INI, so basicaly I have to clear those vars in the INI file for the other user who checks-in so he can gets his own forms, since every new employee will check-in on the same computer, which lead me to have a conclusion that such solution, is not very practical, and therefor I have to find a better way to do it.

Thanks all for the great effort. Regards.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13901728
>...would it work for 3 or 4 subforms ?
I'd probably use multiple environment var's (UseSub1, UseSub2...) or concatenate the 4 results in one. Using @Word in the subform formula would allow you to pick the right value from the concatenated list.

>...NotesUIDocument.InsertSubForm( "SubformName" )
Nope... otherwise we probably would have mentioned it. I'm sure Sjef would have loved to slam it in my face for using an environment variable instead!  ;-))

>...I have to clear those vars in the INI file for the other user who checks-in...
Does that other user use the same INI? Doesn't that raise issues on the default user id and/or location? Or other stored settings? I have no true experience in multiple users on a PC (FYI: there are other questions in EE's knowledge base about that), but on my assignment the launch Notes through a script, that provides each user with its own INI in his personal directory.
However, you could clear the vars in the PostOpen event:
In LotusScript:
   Call Session.SetEnvironmentVar("UseSub", "")
In @functions:
   Environment UseSub:=@Unavailable
But are you sure that's neccessary? Doesn't the next user automatically get his own set of subforms asigned in QueryOpen?

May I ask a question?
What is the subform asignment based on? Isn't it just based on e.g. group membership (or better: userroles) and/or read/edit mode? I'd proces those in @functions in the subform computation.
0
 

Author Comment

by:Faraj1969
ID: 13902039
That's the problem with my assignment, you just touched a sensitive string. lol.

The idea is, when a new employee joins the company, will have to check-in ( filling few forms using a generic ID ), after that, filled in forms will be printed, then some will go to personnel, for his file, some goes to IT, to create his ID and mail file, some goes to communications for telephone and handheld radio, some goes to HQ to start processing his payroll, and so on, and not all forms applys to all employees, thats why I need to ask few questions thru DialogBox, and based on the answers I add SubForms to Main Form. As you can see, all new employees use same ID and same INI file, I tried your solution, the one with Vars A & B, the first time it worked, but next time, they had the values, and so far I found the same subforms added, so I believe clearing the vars is necessary. But, with what you just said, it gave me an idea, that I will try now, and if it works, I'll paste it here right away.

Sjef, keep your hands in your pockets... ;-))

Cheers mate.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 13903731
I can slam with other things too... ;)

Why don't you just ask everything, I mean EVERYTHING, using DialogBoxes? Then you store it all in a document, including the right values in some fields to open the right subforms. And then next time when a user opens the document, all the required subforms will be automatically opened. Add some buttons that will open a DialogBox, e.g. Payroll, Radio, Phone, etc. For the information to be displayed on the Input-form, add one multi-value text-field, separator set to newline, with value
    ra:= @Implode(@Trim(RadioNr:RadioType:...));
    pr:= @Implode(@Trim(PayRollID:....));
    ph:= @Implode(@Trim(PhoneNr:PhoneType:...));
    ra:pr:ph
so the user has at least some overview in between DialogBoxes.
0
 
LVL 13

Expert Comment

by:CRAK
ID: 13907313
My earlier example did not suffer with that: when opening a form QueryOpen gets triggered, asking you to enter a subform.
Only when you skip the question, an earlier value gets users.
What you expirience now is probably caused by the altered approach. E.g. if you only perform the subform computation for the general id, the final id won't redefine them.
Perhaps you could share your code so we can look at it?
0
 

Author Comment

by:Faraj1969
ID: 13936917
I've changed the whole design already, decided to build 5 forms which meets most types of employees, and based on the questions, one or another form will be composed, and also used Controlled Access Sections to hide some subforms if they don't apply.

But the subject is interesting if someone would like to share us with a new idea or so.

Many thanks.
0
 
LVL 13

Accepted Solution

by:
CRAK earned 200 total points
ID: 13937048
In that case you might just as well close it again....
People will find it using EE's search (=Google)!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

839 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