Select all / none buttons in a dialogbox

Hello,I’ve got an application that permits to import datas from a text file. When you have selected the file, indicate the separator, a dialogbox is displayed to choose the fields you want to get. I want to add buttons to select all or none of the fields.

I saw the @SetField formula who works fine… if the values to select are always the same. But they don’t, as you can imagine ! So I tried to dynamically generate the argument to pass to it in LotusScript, but a Evaluate(“@SetField(MyNotesField,”“” & MyList & “”“)”, ns.documentcontext) doesn’t work at all.

What can I do ?

Subject: RE: Select all / none buttons in a dialogbox

Please forgive me if I make a wrong assumption about what you’re doing, but if I do, that might be a hint to provide more detail next time you ask a question.You’re using Dialogbox method or @Dialogbox function to display a dialog to the user.

On the dialog form, you have a keyword field named ImportFields. The keywords are a list of fieldnames read from a file.

The field has a formula to compute the list of keywords displayed. This formula is:

plugh

The keywords do not use alias values.

You want to add a button to the dialog form to “select all” the values in the ImportFields choice list. Here’s the button formula:

FIELD ImportFields := plugh;

The button to clear all the choices has an even simpler formula:

FIELD ImportFields := “”;

Subject: And you are in a maze of twisty little passages all different :slight_smile:

Subject: RE: Select all / none buttons in a dialogbox

Thanks a lot for replying ! Sorry I wasn’t that clear in my first message.

Well, the dialogbox is opened via a LotusScript agent. This agent reads the first line of the file, and regarding of the separator indicated by the user extracts all the avalaible fields names. A NotesDocument is created, and the field that lists the file columns (say it’s called “ColumnList”) is filled with a LotusScript array. Then, this document is opened using the NotesUiWorkspace’s DialogBox method.

I tried to add another field to get the “select all” formula to work :

DocDialogBox.ColumnList = Array_ColumnList

DocDialogBox.ColumnList2 = Array_ColumnList ’ add this line

And in the form used when opening the dialogbox, add this formula on the “select all” button :

FIELD ColumnList := ColumnList2

But it doesn’t work :frowning:

Subject: RE: Select all / none buttons in a dialogbox

I’m really tired of people saying “it doesn’t work” without saying what it does do.

You still haven’t provided enough detail for me to tell what’s wrong. The parts you have shown look OK, but I don’t know what’s in the Array_ColumnList variable (use the debugger to find out). Is it really an array? Does it have the correct values? Did you put the ColumnList2 field on the form? How did you define the field? Does it perhaps contain a formula that’s changing its value? Is it designated as multivalued? What’s the name of the editable field on the dialog form? What is its keyword formula?

Here’s what you should be doing:

You assign two fields before you open the dialog. One is a list of all the fields, which you have named ColumnList2. Another is the list of fields the user wants to import, which you have named ColumnList. The line of code that assigns ColumnList before opening the dialog, should be assigning its default value.

ColumnList is the only field that needs to appear on the dialog form. ColumnList2, you can put on the form if you wish, but if you leave it off, Notes will definitely not change its value when you refresh the form. You want Notes to not change this value, so you can either leave it off, or be careful to define it so that a refresh doesn’t affect it.

The ColumnList field’s keyword formula should be:

ColumnList2

Subject: RE: Select all / none buttons in a dialogbox

Thanks a lot for this answer ! In fact, as you can see to another post I made below, the problem is that this method doesn’t works (the “select all” buttons has no effect) if the field is contained in a layout region - it’s the case in the form I need to modify.

To answer you questions (sorry I though it wasn’t necessary to say that) :

  • the Array_ColumnList contains an array of strings. Each element is the name of a field in the file.

  • the ColumnList field is a Listbox, Editable, with “allow multiple values” checked, and his formula is : ColumnList

  • as previously said, the ColumnList values are initialized in the agent (Document.ColumnList=Array_ColumnList), and those values are OK

  • the ColumnList field is contained in a layout region

I tried as suggested by Thomas Kennedy to add a hidden field “ColumnList2” to the form (text, multivalue, hide from all), change the formula of “ColumnList” to be : ColumnList2. This doesn’t work (witch means the “select all” button has no effect at all).

So I tried to create a sample from scratch, just a little agent and a form with just the 2 fields and the 2 buttons. It works fine ! I then add the layout region, add in it the 2 fields and the 2 buttons… And saw it wasn’t working anymore.

Any suggestion ?

Thanks for help !

Subject: RE: Select all / none buttons in a dialogbox

Here is how I would do it:

  1. Put two fields on your dialogbox form.

FieldList ← multivalue field, hidden. Insert the array into this field before calling dialogbox.

FieldSelection ← multivalue checkbox field, not hidden, uses FieldList for its values.

  1. You can do the Select All button a couple of ways.

If you use formula I believe the syntax is FIELD FieldSelection := FieldList.

Or you could use LotusScript:

dim ws as notesuiworkspace

dim uidoc as notesuidocument

dim v as variant

dim doc as notesdocument

dim item as notesitem

dim tmp as string

dim i as integer

set ws = new notesuiworkspace

set uidoc = ws.document

set doc = uidoc.document

set item = doc.getfirstitem(“FieldList”)

v = item.values

tmp = v(0)+chr$(13)+chr$(10)

for i = 1 to ubound(v)

tmp = tmp+v(i)+chr$(13)+chr$(10)

next i

call uidoc.fieldsettext(“FieldSelection”,tmp)

Note that you can get to the back end objects without saving the document, as long as you are in the form PostOpen or later.

In the R5 client the value-delimiter would be a comma instead, or comma+space.

Subject: RE: Select all / none buttons in a dialogbox

Thanks a lot for this detailed answer ! I just try it, it works very fine… if the “FieldSelection” field is outside a layout region. Otherwise, a click on the “select all” button (with formula FieldSection := FieldList) has absolutly no effect. Actually, the existing form I need to modify has a layout region…Is there something to do to make this work for fields contained in a layout ?

Thanks again !

Subject: RE: Select all / none buttons in a dialogbox

I can’t think of a reason why a layout region would interfere with something as simple as that formula. But then, I can’t think of a reason for a lot of things that happen in layout regions. Try using the script instead and, instead of displaying your form as a dialogbox, preview it; that gives you the option of using the debuggger.

Consider getting rid of the layout region in favor of tables or layers.

Subject: RE: Select all / none buttons in a dialogbox

Again, thanks a lot ! This helps me very mutch, I’ll try these.

Best regards

Subject: RE: Select all / none buttons in a dialogbox

The layout field is different in that it will not accept you adding keyword values that aren’t already in the list. Look at your keyword formula for the field. You keep talking about “the formula” for the field. There are several types of formulas that you could write for a field, so I don’t know which one you’re talking about. If the keyword formula doesn’t calculate a correct list of choices, you won’t be able to assign it those values in your button. You also won’t be able to select the fieldnames from the list because the list won’t be there. If the keyword values don’t exactly match the values you’re trying to assign, there will be a problem!

Subject: RE: Select all / none buttons in a dialogbox

Mr Guirard, to summarize what have been previously said and perhaps be more precise, here are exactly the procedures I follow to create the test cases

Form without a layout region :

  • create a new form named “Test1_NoLayout”

  • add 2 fields, 2 buttons

  • name the 1st field “FieldSelection”

  • make it a listbox, allow multiple values, change the height as needed, use the formula “FieldList” as list of choices

  • name the 2nd field “FieldList”

  • allow multiples values in it

  • in the “paragraph hide when” tab in the field properties, click on the 3 checkkox (hide for Notes, Web and mobile)

  • change the label of the 1st button to “select all”

  • change the click formula to : FieldSelection := FieldList

  • change the label of the 2nd button to “select none”

  • change the click formula to : FieldSelection := “”

Form with a layout region :

  • create a new form named “Test2_Layout”

  • add a layout region

  • create 2 fields and 2 buttons inside it

  • follow exactly the same steps as the other form to prepare fields and buttons

Agent :

Sub Initialize

Dim workspace As New NotesUIWorkspace

Dim Ns As New NotesSession

Dim Db As NotesDatabase

Dim Doc As NotesDocument

Dim MonTab(0 To 3) As String



MonTab(0) = "un"

MonTab(1) = "deux"

MonTab(2) = "trois"

MonTab(3) = "quatre"



Set Db = Ns.CurrentDatabase

Set Doc = New NotesDocument(Db)

Doc.FieldList = MonTab



Call workspace.DialogBox("Test1_NoLayout", True, True, False, False,False, False, "", Doc)

Call workspace.DialogBox("Test2_Layout", True, True, False, False,False, False, "", Doc)

End Sub

The agent can be lauched via a button in the view or the Notes Action menu.

Thanks for your help !

Subject: RE: Select all / none buttons in a dialogbox

Your steps look fine to me, except that the formula in the buttons should say FIELD FieldSelection := whatever, instead of just FieldSelection := whatever. With this one change, I followed your steps precisely, and it works just fine for me both ways. Send me email at us.ibm.com, if you like, and I’ll send you the test database.

Subject: RE: Select all / none buttons in a dialogbox

Andre, thanks for your answer. In fact as I posted just a few moments before you my problem is solved by using the correct syntax for @SetField()

Subject: RE: Select all / none buttons in a dialogbox

I don’t want you to come away from this with the impression that there’s some mysterious problem with field assignments in a layout that forces you to use the more awkward and dangerous @SetField syntax. (The danger is that you will forget the quotes around the field name, which also makes the assignment not work (or work in an way you won’t like). Fields in layout regions work just fine.

Also note that FIELD assignment statements will work with @DeleteField and @Unavailable, whereas @SetField will not.

Subject: RE: Select all / none buttons in a dialogbox

Someone just suggested me to use these click formulas for the buttons :

@SetField(“FieldSelection”;FieldList)

@SetField(“FieldSelection”;“”)

And it works pretty well, either the fields are in a layout region or not.

Well, it’s just a little bit more complicated to add this to the existing form, but at least I’ve got a little sample who works fine.

Thanks all for your help !