Link to home
Start Free TrialLog in
Avatar of Sjef Bosman
Sjef BosmanFlag for France

asked on

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
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

ASKER

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)?
SOLUTION
Avatar of p_partha
p_partha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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! ;)
" 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
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...


Avatar of Andrea Ercolino
Andrea Ercolino

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 ) )>>

You can make the two formulas relative (better) if Hide when is <<Options1 = "">> and Options is <<@Trim( @If( Options1 != ""; Options1:Options2; Oprions1 ) )>>
oops, a typo, this one is OK <<@Trim( @If( Options1 = "Ma"; Options1:Options2; Options1 ) )>>
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 :)
well, the sentence <<Old Fashioned Way>> was clearly a citation from sjef_bosman's contribs to this site ;-)
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 )

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 = "">>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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?
Order of creation should be irrelevant.
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!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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??
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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!