• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

Creating dynamic checkboxes

Good evening all,

I am collecting information from a categorized view by manager name which lists the folks that report to that manager. Each manager has a different number of people working for them.  I'd like to show the information from that view in a form that has the manager's name at the top, of course, and then the people that report to him, each on their name on a line with a few checkboxes to the right of their name. How can I do this especially since the number of people would be dynamic. For example:

Manager:  Joe Something


                                  Class 1              Class2               Class3            
     Jane Someone        chkbox here       chkbox here       chkbox here
     Bob So & so           chkbox here       chkbox here       chkbox here

It'll give the manager a place to note whether or not a class was taken. Being able to include the date the class was taken would be a bonus (either below or to the right of the checkbox). I believe that I will need to deal with arrays, redim preserves, etc. I've been trying to figure out how to do it and have been able only to get a checkbox next to the name of the reports and having only the one column. Creating tables rows and fields as needed? Profile documents? My brain is going around and around. Can it even be done? What am I missing? Argh! I just thought of something ... there may be a different number of classes each year. Let's just deal with that dimension later. Let's just assume 3 classes for now. Thank you for your suggestions and help.

I am, as ever, in learning awe - Notes Rookie (on R6.5)
  • 7
  • 5
  • 4
1 Solution
Why not embed the view in the form?  You can create a table with one row, two columns and embed the view in one column, categorized according to Manager, and the second column can provide an explanation of what the list provides.

The columns for Class 1, Class 2, Class3 can be icons: @if(Class1<>"";168;0).  And if you don't want the manager to be able to open the document, put a bit of code in the queryopen view event.

Second suggestion is coming up.
Sjef BosmanGroupware ConsultantCommented:
Halfway describing the problem you head off into a solution again... That's also the reason why your head starts spinning. Let's get it fixed.

> I'd like to show the information ...
What information? Please don't make us guess.

> I believe ...
That's good :) But not very useful when it comes to programming. ;)

What you need is a standard approach for all problems you have to solve. It's an old method, but usually infallible: Describe, Analyse, Design, Develop, Implement (DADDI). The Description you gave is incomplete, so you my have to work on that. To Analyse, I'd like to have an ERD: Entity Relationship Diagram. In words will do. Otherwise, something like this:

Manager  1-->n  Employee  1-->n  Class ??

- one manager has n employees (n>=0)
- one employee did n classes

Now, you immediately see that you have a problem when you put only 3 classes in a form of a manager. Other issues:
- what is a class?
- does a class have properties?
- wouldn't it be better to put class attendance in a separate document, with class_started, class_ended, grade, result, etc??
Sjef BosmanGroupware ConsultantCommented:
Third suggestion is coming up... ;)
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Here is another creative way to show those check marks dynamically...
      Create two image resources:  chk_no.gif, chk_yes.gif  (box with check in it, box with "x" in it)

      You have your employee class form with the class1, class2, class3 values.  At the bottom of this form you insert a parsedfield that will combine the values into a single line.
            This parsedweb field concatenates an "<img src=" tag with a chk_no or chk_yes image for the employee:
                             (employeename|<img src="YES image">|<img src="No image">|<img src="YES image">|  and so on)

      Then create a lookup view with two columns, the first is the manager's name, categorized.
      The second contains the parsedweb field

      Then you have your report form.  This is a form set with saveOptions = "0" so it can't be saved.
            The first field you select a manager's name from a dbcolumn lookup to your lookup view
                        A hidden field collects all the parsedweb employees in column#2 via a dblookup and puts those values in a hidden, multivalue field.
            A table on the form displays the results, using the images as the checked values.

Caveats:  64K dblookup value
        32K field limit value in the return field.
The Employee Form:

 I used the fields you posted:

At the bottom of this form I put a parsed field:
Field:  parsedweb
Datatype:      Text
Help Description:      [Not Assigned]
Field Type:      Computed
Sign When Mailing/In Section:      No
Encryption:      Disabled
Update Requires Editor Access:      No
WEBNO := "<img src=\"/" + @WebDbName + "/chk_no.gif?OpenImageResource\" width=\"14\" height=\"13\" alt=\"No\"><BR>";
WEBYES := "<img src=\"/" + @WebDbName + "/chk_yes.gif?OpenImageResource\" width=\"14\" height=\"13\" alt=\"Yes\"><BR>";
FullList := Class1 : Class2 : Class3 + "|";
x := "|" + @Right("~" + FullList; "~|");
ClassList := @ReplaceSubstring(@Implode(@Replace(@Replace(FullList; x; "CHKNO|"); "1|"; "CHKYES|")); " "; "");
WebList := @ReplaceSubstring(@ReplaceSubstring(ClassList; "CHKNO"; WEBNO); "CHKYES"; WEBYES);
Employee + "|" + WebList;

-chk_no.gif was an image resource:  box with an "X" in it.
-chk_yes.gif is an image resource: box with a check in it.
-Class1,2,&3 were check boxes with "Yes|1" as the formula.  When you checked the field, the value returned is "1", else it is blank.

Note: <img src=\"/" + @WebDbName << is tested local, so there is a leading "/" so the webdbname points to my local test database

When you complete and save the form the parsed web field displays:
Mary Jones|<img src="/test%204.nsf/chk_no.gif?OpenImageResource" width="14" height="13" alt="No"><BR>|<img src="/test%204.nsf/chk_no.gif?OpenImageResource" width="14" height="13" alt="No"><BR>|<img src="/test%204.nsf/chk_yes.gif?OpenImageResource" width="14" height="13" alt="Yes"><BR>|;
Now I have my lookup view:  
ViewName:      Rookie
Col1:            Manager, categorized
Col2:            parsedweb
Then I completed a display form:
Field:      SaveOptions, computed, formula="1"
Field:      Form, computed, hidden, "Rookie Display"

Field:      Manager, dialoglist, formula=@DbColumn("":"NoCache";"";"Rookie";1)

Button:      Show Class Results
      Sub Click(Source As Button)
      Dim Session As New NotesSession
      Dim db As NotesDatabase
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Set db = session.currentdatabase
      Dim doc As NotesDocument
      Set uidoc = ws.currentdocument
      Set doc = uidoc.document
      doc.display = doc.classlist
      Set uidoc = ws.editdocument(True, doc)
      Call uidoc.reload
            End Sub

Field:      ClassList,
      computed, multivalue text, separate entries with new line, hidden.
Then I created a table with two rows, four columns
First Row:      
      Titles - Employee Name, Class1, Class2, Class3
Second Row:      
Column1: (Employee Name)
      ComputedText - Passthrough HTML
      N1:="<font size=\"2\" face=\"arial\" color=\"#000000\">" + @Word(ClassList;"|";1) ;
      N2:=N1 +"</font><BR>";
      Computed Text - Passthrough HTML

      Computed Text - Passthrough HTML

      Computed Text - Passthrough HTML

You would have to add a bit of formatting, and in order for the computedtext to display, you have to reload the form, both in client and in web.  But, you can have the manager's field automatically select the current user, and it will flash correctly for notes web and client.
Hey, sjef.. this one was fun... see if you can add to it..   Also, used a bit of your parsing formula :)
Ah, forgot to mention, the computedTExt only flashes when you reload the document, which is why I put a button with a click formula.  For web, you need to adjust to reload the document.
notesrookieAuthor Commented:
Wow - lots of information to digest. In order to elaborate, the categorized view that I am collecting the information from is a manager view with his subordinates listed. I'd like to create a form that enables each of these managers to have a document where the manager can click on checkboxes as to whether or not each of their subordinates have taken a required training class. These checkboxes would solely exist because they would appear calculated on the basis of the existence of an employee. Currently there is no class form that has the information that a student attended and when it was held (no grades luckily - phew!). I'll be digesting and testing and I'll get back to you.

Please let me know if I can supply you with more information. Thank you.

notesrookieAuthor Commented:
I apologize if my initial description was confusing. All the manager wants to do is to be able to have a quick visual in this form as to whether or not his suboridinates hava taken a class. Instead of printing out a bunch of emails and having to constantly refer to them in individual folders, he/she can check off the class in this "dynamic" (because there are many managers with a different number of employees) form. I'm sorry if I led you astray.
notesrookieAuthor Commented:
So there is no corresponding form for the class, just 2 forms. Form1 has the managers and subordinates names and Form2 has the manager'name, current year and the classes that need to be taken. Does this make more sense?
Sjef BosmanGroupware ConsultantCommented:
> All the manager wants to do ...
Yeah, sure, we've heard that before. And then they want you to add the date they did the class, which means you're up to your pretty neck in trouble. And then they say: can you give me an overview of all people who attended that class??

Gouverner, c'est prévoir...

where the manager can click on checkboxes <<  Then you'd pretty much have to do an embedded view with column editing in place.

My second suggestion was a way to show a list of who took the class.  However, you could add an "onclick" event to each of the yes/no check boxes and make it change the underlying value, but it's going to be clutsy..

    Check the image, onclick event finds the class form, changes the value and then the displayed form has to reload.

You can add a link to the employee record on the display form, and let it open the actual record to change.

But if they're going to change the class or click off the class, then embed the view and select the manager's name as the category.  

sjef, I haven't tried editing columns in an embedded view.. have you?
hee, hee... if you can't use edit columns in the embedded view, then you'd have to use... silence, suspense..


Embedded view with embedded editor (and it doesn't have to be the real form, it can be a different, check-only-the-class-box form)

So you can create a form that either collects the manager's name when it opens and shows the correct category in the embedded view, or have a dialog box that will allow you to select the manager's name and a list of employees in the categorized view.
    -- for this one, I have a default, blank view that has one form listed: Please select a manager's name!

When they select a manager's name, the computed view loads to the manager's name category and displays the list of employees.

If you can't use the column editing feature in an embedded view, then when they click on a document in the view, it can appear in an embedded editor. Else, they can click and open the document to edit it.

notesrookieAuthor Commented:
sjef - Yes, they tend to start of that way, "they just want to" and then the additional requirements come in they wonder why you can't turn it around in less than a day.

marilyng - Embedded editor ... hmmmm. Haven't used that one yet. It should be interesting.

Let me check it out and I'll get back to you. Thanks for pointing it out to me.
notesrookieAuthor Commented:
Hah! They did come back with more just as you predicted, sjef. But I was able to use marilyng's solution to implement what they wanted. I used an embedded view with single category in a form, set the class columns as editable and used the inviewedit event to allow changes to be made from the view and so they can be made from the embedded view as well. But instead of checkmarks, there is a validation formula in the inviewedit event to check for "Y" or "N". So the managers can now look at the form for a quick visual or open each subordinates document to look at class attendance. Sheesh! Why is it that when they want something really simple it tends to be more complicated than anything you've ever done and when they make it more complicated that it sometimes simplifies things?

At any rate, thank you again for the great suggestions and ideas!
Sjef BosmanGroupware ConsultantCommented:
Your hobbyhorse wins again, Marilyn!  
You know what happens, your solution sparks an idea - you see when they asked for something, they had a blank slate in their minds because they couldn't envision how it could be done.  When you provide a visual example, it sparks creativity and then they are reminded of something else they needed...

That's a good thing, BTW.  Keeps you working. :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 7
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now