Need a trick to change field selection values

Hi All,

In a form, there is a field called Options: Checkbox, editable, formula for choices is AllOptions, and both Refresh fields and Refresh chocies are selected. The formula in the CfD-field AllOptions is
     @If(Options="Ma"; "Send as mail | Ma":"Send on Save | Sd"; "Send as mail | Ma")

What I want is that, if the user selects the Send as Mail option,  a second option is displayed, namely Send on Save. This works... almost, I only have to press F9 to make it show up.

Calling Refresh from the PostRecalc is illegal, but would be the solution if it weren't recursive. I already tried to put a GoToField("nextfield") in the Entering of the Options-field, but this effectively blocks the user from doing anything in that field. Which is by all means a great feature, but not for this purpose (equivalent to using InputEnabled, but works in R5 as well :).

How can I do this using more or less standard stuff? I think I know some ways around this, but your tricks are welcome!

Sjef
LVL 47
Sjef BosmanGroupware ConsultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantAuthor Commented:
I found, on the 3rd tab of the Field Properties box:
   Special Notes Client Event Options, Run Exiting/OnChange events after value change

1) Would this be a solution?
2) Does it exist in R5 (for compatibility reasons)?
0
p_parthaCommented:
Did you enable "AUtomatically refresh fields" at the form level?...

Partha
0
Sjef BosmanGroupware ConsultantAuthor Commented:
Hi Bro, as a matter of fact, I thought about writing that I didn't use that option, since I suppose it wouldn't make a difference since 1) it's not a refresh field that needs to be done, but a refresh choices, and 2) the refresh fields is already triggered because it is set on the field itself. I'll try tomorrow.

Thanks for thinking along, but I'm off, to a refreshment and some peanuts. And bed afterwards. All letters start to look identical, and I seemn to be unble to  fins the keyus on myu keibord. See ya! ;)
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Bozzie4IT ArchitectCommented:
" Run Exiting/OnChange events after value change" is R6 only.  I don't know if it has an equivalent in R5 (or maybe it's even standard in R5?)

What you could do is store the values not in the field itself, but in a separate field.  Now put code in the QueryRecalc to update this field BEFORE it will use this field's values to update the checkbox (is that clear ?)
When refreshing, (I hope that) first the field with the values will be updated thru the QueryRecalc event, and then the checkbox will be updated with this field's values ....

cheers,

Tom
0
Sjef BosmanGroupware ConsultantAuthor Commented:
Using QueryRecalc would be one of the ways around the problem, but it is "New with R6" says the Help db. So I had already skipped it. The hard part is that a PostRecalc is too late, since field choices are refreshed before that when the field with the choices still has the old values. An additional Refresh would do, but how to trigger it? Preferably without my favourite object (a NotesTimer, indeed!).

Must be a hard nut to cra(c)k this one...


0
Andrea ErcolinoCommented:
What about the "Old Fashioned Way"?

-- an Options1 field, editable checkbox, with only one choice <<Send as mail | Ma>> and Refresh fields on keyword change
-- an Options2 field, editable checkbox, with only one choice <<Send on Save | Sd>>  and Refresh fields on keyword change, and Hide when <<Options1 != "Ma">>
-- an Option field, computed, with formula <<@Trim( @If( Options1 = "Ma"; Options1:Options2; Oprions1 ) )>>

0
Andrea ErcolinoCommented:
You can make the two formulas relative (better) if Hide when is <<Options1 = "">> and Options is <<@Trim( @If( Options1 != ""; Options1:Options2; Oprions1 ) )>>
0
Andrea ErcolinoCommented:
oops, a typo, this one is OK <<@Trim( @If( Options1 = "Ma"; Options1:Options2; Options1 ) )>>
0
Sjef BosmanGroupware ConsultantAuthor Commented:
I seem to remember vaguely that I myself sugegsted something like this not so very long ago. Without the typo's...

It is indeed a possibility, and probably the only left that can be called "more or less standard". That there are additional fields is not a huge problem, but an important disadvantage is that I get into trouble when I have the field(s) displayed with the choices in 2 columns or when there are more choices than the two I used for the example. So I will have to place the fields on separate lines (which is also required to make hide-when work, unless I place them in separate table-cells.

Best suggestion so far :)
0
Andrea ErcolinoCommented:
well, the sentence <<Old Fashioned Way>> was clearly a citation from sjef_bosman's contribs to this site ;-)
0
Andrea ErcolinoCommented:
the solution I gave above can be extended easily to multiple groups of options, as follows

-- Options1: checkbox editable, Refresh fields, Allow synonyms, Enter choices
option 1 | opt1
option 2 | opt2
option 3 | opt3
option 4 | opt4

-- Options2: checkbox editable, Refresh fields, Allow synonyms, Refresh choices, Use formula
opt1 := "option 1.1 | opt11":"option 1.2 | opt12":"option 1.3 | opt13";
opt2 := "option 2.1 | opt21";
opt3 := "option 3.1 | opt31":"option 3.2 | opt32";
opt4 := "";

@Trim(
 @If( @Contains( Options1; "opt1" ); opt1; "" )
 : @If( @Contains( Options1; "opt2" ); opt2; "" )
 : @If( @Contains( Options1; "opt3" ); opt3; "" )
 : @If( @Contains( Options1; "opt4" ); opt4; "" )
)

-- Options: Text computed, Allow multiple
@Trim( Options1 : Options2 )

0
Andrea ErcolinoCommented:
a little better, if we extract the Options2 formula for choices in a new AllOptions2 multivalue, always hidden, CFD field, then we can have the following "hide when" formula for Options2 that works fine: <<Options1 = "" | AllOptions2 = "">>
0
Bozzie4IT ArchitectCommented:
Darn... I though I had it with the QueryRecalc :-)

Back to old-school antique notes programming :-)
0
qwaleteeCommented:
If AllOptions is above Options, it will work.  That's the reaosn you needed the extra refresh.

Want to prove it?

Create -> Design -> Form

Create -> Field

Name it AllOptions, computed for display, allow multiple values, formula      @If(Options="Ma"; "Send as mail | Ma":"Send on Save | Sd"; "Send as mail | Ma")

Press Control-End

Press Enter

Create -> Field

Name it Options, Checkbox, Refresh on keyword change, Refresh choice on doc refresh, Formula for choices -- AllOptions

Design -> Preview in Notes

Works like a charm.
0
Sjef BosmanGroupware ConsultantAuthor Commented:
But... That's how it is in the form! I'll check again, don't worry. Maybe I'll create a test form, to try it out. Could it be that the order of creation is important?
0
qwaleteeCommented:
Order of creation should be irrelevant.
0
Sjef BosmanGroupware ConsultantAuthor Commented:
Apparently the choices are refreshed BEFORE the form is refreshed. Makes sense, for the content of the field might have to be adapted to the choices that are allowed. Anyway, it doesn't work as described above :(

I even had the Choices-formula in the Options field itself, didn't work.

YOU AIN'T GONNA BELIEVE THIS! :-)

I cracked it, but don't tell me please that you knew all along! The solution is absolutely mind-boggling: I added a simple formula in the Input Translation of the Options field, namely... Options. I reckoned: Options had its old value when the AllOptions field was re-evaluated, so I had to force to compute Options before that. I assumed the Translation formula could just be doing that, and BINGO!
0
Andrea ErcolinoCommented:
BRAVO
0
qwaleteeCommented:
Sjef,

I did not need to do the Translation Formula bit in my minimalist test.  On 5.0.11, everything worked like a charm exactly as I described it.

What version are you using?
0
Sjef BosmanGroupware ConsultantAuthor Commented:
6.0.3

I didn't create a new form and field yet, I'm just too happy that it works now. Well, let's test it rightaway...
Nope, doesn't work, the CfD field has the correct values, but the checkbox doesn't have all the choices. If I change the Translation formula... Like Magic!!

I wouldn't  know if this behaviour is corrected in 6.0.later or 6.5.something. Maybe someone else can test this? Tom??
0
Andrea ErcolinoCommented:
I tested it on 6.5.1 and it didn't work as described by qwaletee
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sjef BosmanGroupware ConsultantAuthor Commented:
Thanks RAPUTA. So we have a new Notes "feature" indeed, to be added to the long list!  Yeaaah! :)

Any news on 6.0.4 or 6.5.latest?
0
Sjef BosmanGroupware ConsultantAuthor Commented:
PAQ/Refund would have been "right", since I found the solution, but I decided to give the points for your efforts in assisting me during some "difficult" hours. Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.