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

Populating a SendTo Fields

I have a view called (Users By Group) - the view is setup like this

Group             User                Email

Owner        Bob Roast          broast@email.com
Worker       Chuck Cheese    ccheese@email.com
ETC..           etc....               etc.....

I have a field in my form called GroupSelect (Checkbox)  Values= Owner
                                                                                               Worker
                                                                                               All
Then I have SendTo field

I would like for when GroupSelect = Owner - the SendTo field is set to dialogbox and shows all the users created in the database but only the ones in the owner group are checked - this would work for any selection and if all is selected all names are checked.

I was trying to use this as the default for SendTo

result := @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; GroupSelect; "Username"));
@If(@IsError(Result);"";result)

0
Jaziar
Asked:
Jaziar
  • 18
  • 15
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
And you set the correct properties for your fields? GroupSelect must have "Refresh document when value changes" (or whatever the name is) and SendTo must have "Refresh choices when document is refreshed". The default is okay, but what is the formula for the choices of SendTo?
0
 
JaziarAuthor Commented:
The issue is I want to show all users from the view but only check the ones in the selected group.
Group Manager is selected the only user in the group is Joe - I also want to see Bob and Chuck just in case I need to select them

[] Bob
[] Chuck
[/] Joe

The way the code is now the only name in the SendTo is Joe
0
 
Sjef BosmanGroupware ConsultantCommented:
Did you set the properties as I said? What's the formula for the choices, and what's the formula for the default value? If necessary, or just for verification purposes, you could create a computed for display-field, multi-value, with the choices-formula in it, and use that field as the checkbox-choices formula.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
JaziarAuthor Commented:
Yes both fields refresh on the select change.

No formula on [GroupSelect] - just a check box field with the values of Owner, Worker, All

I may not be possible to do what I want.  Right now when I click owner - all the owners show up in the SendTo
                                                                           when I click Worker - all the workers show up in the SendTo

I want to see all the users from the view and the ones that are checked are from the specified group.


Group             user          

Bob              Owner                     Right Now when I select Owner in the GroupSelect FIeld
Chuck           Owner                     my sendTo dialog FIeld looks like this
Sam             Worker                                                               [ ] Bob
Linda            Worker                                                               [ ] Chuck
Stan             Worker                                                               [ ] Carla
Carla            Owner                    
                                                  I want to click the SendTo Field and see (if Owner is selected)
                                                                                             [x] Bob
                                                                                             [x] Chuck
                                                                                             [ ] Sam
                                                                                             [ ] Linda
                                                                                             [ ] Stan
                                                                                             [x] Carla
                                                  I want to click the SendTo Field and see (if Worker is selected)
                                                                                             [ ] Bob
                                                                                             [ ] Chuck
                                                                                             [x] Sam
                                                                                             [x] Linda
                                                                                             [x] Stan
                                                                                             [ ] Carla
                                                 I want to click the SendTo Field and see (if All is selected)
                                                                                             [x] Bob
                                                                                             [x] Chuck
                                                                                             [x] Sam
                                                                                             [x] Linda
                                                                                             [x] Stan
                                                                                             [x] Carla
0
 
Sjef BosmanGroupware ConsultantCommented:
No, ONE field should have "Refresh fields on keyword change" but the SendTo field should have "Refresh choices on document refresh"!

You might need an additional refresh to make this work, but first set the properties right.
0
 
JaziarAuthor Commented:
The properties are as you stated.
0
 
Sjef BosmanGroupware ConsultantCommented:
So the default formula is the one you give above, and the choices formula should be something like
    result := @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; "All"; "Username"));
    @If(@IsError(Result);"";result)

If with "All" you get all usernames.
0
 
JaziarAuthor Commented:
The names come in and out of the SendTo field correctly.  If I select Owners I get all the owners, if I select workers I get all the workers.  I want both with the correct ones checked.  I think I need to somehow change my default value formula
0
 
JaziarAuthor Commented:
result := @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; "All"; "Username"));
    @If(@IsError(Result);"";result)

When I put this in for my GroupSelect - I dont get any choices to select from
0
 
Sjef BosmanGroupware ConsultantCommented:
Ah. I might have seen the light :) Is this what you want: when the field GroupSelect is changed, then you want to change the SendTo field as well? But that's not the default value. The default value is computed and used when the field doesn't have a value yet, so either when the document is created or when an existing document is opened and the form has a new field that's not in the document.

You don't want to change the default value, you want to change the real value of the field. Then you have to do a @SetField("SendTo"; ....) or so, in the PostRecalc event.

But what if the user already created the document, and he changes GroupSelect? SendTo has a value, do you want it to be overwritten?
0
 
JaziarAuthor Commented:
After the document is created and sent off - the document is no longer editable.
So they can not go back and change it
0
 
Sjef BosmanGroupware ConsultantCommented:
Okay, if you use PostRecalc to set or reset the SendTo field, then every time the PostRecalc is called the content of the SendTo is reset to a default value, even if the user changed it, i.e. selected or deselected values. Can they save the document without it getting blocked for editing?
0
 
JaziarAuthor Commented:
they create and send and then it saves - I am guessing they can save as a draft and then go in and send
0
 
JaziarAuthor Commented:
I am thinking we would need something like

If NagView(view) != "" {

             IF GroupSelect = "Owner" then
                 check values from @DBLookup "Owner"
            endIF
            If  GroupSelct = "Worker" then
                 check values from @DBLookup "Worker"
            endif
}
else{
     check all values from @dblookup
}
0
 
Sjef BosmanGroupware ConsultantCommented:
Right... but when do you want to execute that formula? When the form is opened? How to decide the user never changed the SendTo field? Or you intend to bluntly overwrite the SendTo values? The "check values" is nothing more than a @SetField("SendTo"; ...), because all checked values are the value of that field.
0
 
JaziarAuthor Commented:
should blunty overwrite the SendTo Values

If I select Owners, then change it to Workers I want the values to change.  So I say yes lets over write the values

does the formula belong in the select Group Field?
0
 
JaziarAuthor Commented:
Also bosman - I want to thank you for staying with me on these issues.  I am in a tight spot on this database and your help has been and continues to be great!!!!
0
 
JaziarAuthor Commented:
Are you saying that have the default value for the sendto set to show all users, then some action will assign the values with a @SetField.  If that is the case where should I run the action?
0
 
JaziarAuthor Commented:
What if I did a SendTO Button and the button poped a dialog form with a field for group selection and even maybe A check box field that showed a each users name and when the user finished with the dialog and hit ok the checked values populated the actual SendTO Field on the request form?

Is this too much?
0
 
Sjef BosmanGroupware ConsultantCommented:
I think you'll always have problems with the single field approach.

The DialogBox or button you can always do, and it's a much better idea. I think you need 2 buttons actually: one to change the value, and one called Reset, to set it so the initial value you want. Make SendTo computed, keywords, with the choices-formula as it already has. The buttons can change the value of SendTo, but it cannot be changed directly on the form. I'd leave the group-selection field on the main form, otherwise you'd end up in the same trouble as now. What you could do, in the PostRecalc of the form, is use this formula:
    result := @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; "All"; "Username"));
    @SetField("SendTo"; @If(@IsError(result); ""; SendTo=""; result; SendTo))
When the fields on the form are recomputed, it would change SendTo only if it is empty. The result would be that SendTo would be populated on the first selection of GroupSelect.
0
 
JaziarAuthor Commented:
can you show me a little code of what a button would look like - is it calling a form?  does the form only have one field on it?
0
 
Sjef BosmanGroupware ConsultantCommented:
You have R6 eh? There are new calls of NotesUIWorkspace.Prompt, e.g. PROMPT_OKCANCELLIST, the same functionality exists in @Formula language.

Some code (without testing as usual :)):
    defaults:= ..... your @DbLookup of the default values;
    choices:= ..... your @DbLookup of all values allowed;
    st:= @Prompt([OKCANCELLISTMULT]; "title"; "prompt"; defaults; choices);
    @If(st=""; ""; @SetField("SendTo"; st))
0
 
JaziarAuthor Commented:
I have R6 but the rest of the company  has R5
0
 
Sjef BosmanGroupware ConsultantCommented:
Check in the R5 help db if it exists...
0
 
JaziarAuthor Commented:
Ok I now see where you are going with this - I got this much working.  But it still only shows the people in the group and not everyone in the list - it may not be doable.  
0
 
Sjef BosmanGroupware ConsultantCommented:
But it must be doable. What are both your formulas, i.e. the default and the choices formula?
0
 
JaziarAuthor Commented:
defaults:= @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; "All"; "Username"));
choices:= @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; EmailAss; "Username"));
@If(@IsError(Result);"";result);
st:= @Prompt([OkCancelListMult]; "title"; "prompt"; defaults; choices);
    @If(st=""; ""; @SetField("SendTo"; st))

When I click the button I get the correct values for each group selected.

so if Owners is picked

I get all the owners - but I need the option to add people from the workers as well.  

I wish there was a way to click the button - a dialog opens with a checkbox field.  The checkbox field displays all the users from the groups and only the users in the owner field is checked?
0
 
Sjef BosmanGroupware ConsultantCommented:
Swap the formulas for choices and defaults...
0
 
Sjef BosmanGroupware ConsultantCommented:
You can create a checkbox-field on a form to be shown in a DialogBox indeed. A lot more work... *yawn* ... not today, because I'm off in a few minutes (22:23 here). I'll read your comment in the morning.
0
 
JaziarAuthor Commented:
ha ha ha - that does work - tacking on 50 extra points.  I am now in the process of cleaning this up then I will close it.
0
 
Sjef BosmanGroupware ConsultantCommented:
Good. Have a pleasant evening!
0
 
JaziarAuthor Commented:
Good Morning Bosman,
   I would truly love to some how reflex the values that we are showing with the @Prompt with a checkbox maybe on a differnt form.  That way the user will see all the names with a checkbox.  

choices:= @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; "All"; "Username"));
defaults:= @Name([CN];@DbLookup("":"NoCache";""; "(Users By Group)"; EmailAss; "Username"));
@If(@IsError(Result);"";result);
st:= @Prompt([OkCancelListMult]; "title"; "prompt"; defaults; choices);
    @If(st=""; ""; @SetField("SendTo"; st))
0
 
Sjef BosmanGroupware ConsultantCommented:
Good morning to you too! Sorry to react this late...

I can imagine that that's what you want, a DialogBox. Bear in mind that the size of a DialogBox is always fixed, so that there is room on it for only x names. So if you only have groups at th emoment with a maximum of 6 users, don't make the DialogBox too tight, for there will be a group with 7 users some day.

The logic is pretty much the same. Instead of the @Prompt, you call a DialogBox. Sadly, the call only returns True (okay) or False (cancelled), so the DialogBox can set the new value of SendTo all by itself.

Make a new form, enclose the name in parentheses and give it a normal alias in such a way that you (and your successors) know that it's only used in a DialogBox. The DialogBox runs in the SAME document as the underlying form, so you have all its fields at your disposal.

Well, that's about the basics, but there is much more to tell about it. May I suggest to open a new question for that purpose? But first, study the DialogBox call and other information about it in the Designer Help database.
0
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: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 18
  • 15
Tackle projects and never again get stuck behind a technical roadblock.
Join Now