SDerrick
25th April 2007, 15:46
I have a problem getting the fields of a form to do what I want to do.
I have a simple maintain list session. The first three fields are:
Country, Area, Sold-to BP
I want the session to only allow input to one of these fields so I wrote the following code:
field.tdsls902.ccty:
check.input:
if not isspace(tdsls902.ccty) then
tdsls902.area = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.area","tdsls902.ofbp")
endif
field.tdsls902.area:
check.input:
if not isspace(tdsls902.area) then
tdsls902.ccty = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.ccty","tdsls902.ofbp")
endif
field.tdsls902.ofbp:
check.input:
if not isspace(tdsls902.ofbp) then
tdsls902.area = ""
tdsls902.ccty = ""
disable.fields("tdsls902.area","tdsls902.ccty")
endif
This appears to work fine unless you hit undo. This then assumes the default from the previous row and therefore does not enable all the fields again. For each new row I want the user to be able to input to any of the 3 fields.
Can someone tell me the best way to do this please.
Cheers
Simon
arrakis123
25th April 2007, 15:55
why dont you disable fields step by step?? for example:
field.tdsls902.ccty:
before.input:
if tdsls902.area <> "" or tdsls902.ofbp <> "" then
attr.input = false
endif
and that do in 3 fields, on before.input
george7a
25th April 2007, 16:06
Hi,
If I understood correctly you need to enable the fields when the three are empty. right?
Use enable.fields() function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_enable_fields) to enable the three fields when they are all empty. Example:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields(tdsls902.ccty)
enable.fields(tdsls902.area)
enable.fields(tdsls902.ofbp)
endif
I hope it helps,
- George
SDerrick
25th April 2007, 17:05
why dont you disable fields step by step?? for example:
field.tdsls902.ccty:
before.input:
if tdsls902.area <> "" or tdsls902.ofbp <> "" then
attr.input = false
endif
and that do in 3 fields, on before.input
Thanks for your response.
This is how I started, with attr.input. Using this does not work. It does not disable input at all. Using the debugger I can see that the value of attr.input is correctly set to false but then it allows me to enter and save values in more than one field.
arrakis123
25th April 2007, 17:29
try to refresh the fields, BaaN is a little crazy...Xddd
display.all()
refresh()
SDerrick
25th April 2007, 17:34
Hi,
If I understood correctly you need to enable the fields when the three are empty. right?
Use enable.fields() function (http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_enable_fields) to enable the three fields when they are all empty. Example:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields(tdsls902.ccty)
enable.fields(tdsls902.area)
enable.fields(tdsls902.ofbp)
endif
I hope it helps,
- George
Thanks for your help. In which section would you put this code? I tried it in a before.input section. It doesn't prevent the problem of when undo is used. Whenever I use undo and want to start again the fields which were previously disabled are still disabled. I am really looking for a section that is executed before a new record is created.
george7a
25th April 2007, 18:13
Did you try it in the after.input section? You can also put it in the same section and add "else" with an extra condition. I have just tried it and it worked for me.
field.tdsls902.ccty:
check.input:
if not isspace(tdsls902.ccty) then
tdsls902.area = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.area","tdsls902.ofbp")
else
if isspace(tdsls902.ofbp) and isspace(tdsls902.area) then
enable.fields("tdsls902.area","tdsls902.ofbp")
endif
endif
field.tdsls902.area:
check.input:
if not isspace(tdsls902.area) then
tdsls902.ccty = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.ccty","tdsls902.ofbp")
else
if isspace(tdsls902.ccty) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.ofbp")
endif
endif
field.tdsls902.ofbp:
check.input:
if not isspace(tdsls902.ofbp) then
tdsls902.area = ""
tdsls902.ccty = ""
disable.fields("tdsls902.area","tdsls902.ccty")
else
if isspace(tdsls902.area) and isspace(tdsls902.ccty) then
enable.fields("tdsls902.area","tdsls902.ccty")
endif
endif
mbdave
26th April 2007, 13:59
Hi
i advice you to write anable and disable code always in when.field.changes or
before.display.object for its fine tuning.
SDerrick
3rd May 2007, 15:49
try to refresh the fields, BaaN is a little crazy...Xddd
Yes, just tried it. refresh() doesn't re-enable the fields and display.all() in the before.display.object section reactivates the same section. On the second time it hits display.all() I get a fatal error and Baan hangs.
I'm sure things used to be easier than this:mad:
shah_bs
3rd May 2007, 21:01
The attr.input = false should be done in the before.field: events.
For example:
field.tdsls902.area:
before.field:
if not isspace(tdsls902.ccty)
or not isspace(tdsls902.ofbp)
then
attr.input = FALSE
endif
This is how I started, with attr.input. Using this does not work. It does not disable input at all. Using the debugger I can see that the value of attr.input is correctly set to false but then it allows me to enter and save values in more than one field.
Simon,
I noticed you are on LN, refer to the Tools Programmer's manual-
SSA ERP LN 6.1 Programmers Guide
Other deprecated predefined variables / functions
--------------------------------------------------------------------------------
Deprecated predifined variables
The following predefined variables are deprecated:
attr.adju
attr.bitset
attr.echo
attr.enum.mask
attr.imax
attr.input
attr.maxlen
auto.nextform
fattr.descr$
fattr.helpfile$
fattr.toplines
You have to use disable.fields() and enable.fields() functions.
Alternative way of solving this issue it to put all the field enabling/disabling statements in a function, for example - enable.disable.approval.fields() and call it from before.display.object, or check.input or when.field.changes or from choice.recover.set & on.choice (the standard form command for Undo).
Also note, that if you have a DAL for the table then the check.input sections from the UI scripts are not executed.
SDerrick
4th May 2007, 12:58
Ok, I've done it. For anyone who is interested here's how
before.display.object:
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
field.tdsls902.ccty:
before.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
check.input:
if not isspace(tdsls902.ccty) then
tdsls902.area = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.area","tdsls902.ofbp")
endif
refresh()
after.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
field.tdsls902.area:
before.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
check.input:
if not isspace(tdsls902.area) then
tdsls902.ccty = ""
tdsls902.ofbp = ""
disable.fields("tdsls902.ccty","tdsls902.ofbp")
endif
refresh()
after.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
field.tdsls902.ofbp:
before.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
check.input:
if not isspace(tdsls902.ofbp) then
tdsls902.area = ""
tdsls902.ccty = ""
disable.fields("tdsls902.area","tdsls902.ccty")
endif
refresh()
after.input:
if isspace(tdsls902.ccty) and isspace(tdsls902.area) and isspace(tdsls902.ofbp) then
enable.fields("tdsls902.ccty","tdsls902.area","tdsls902.ofbp")
endif
refresh()
My stupid error was that I had forgotten to put the "" around the field names. This is why enable.fields did not work (I got no error though).
Thanks for all your help and advice.
Simon
kysersoze12
10th May 2007, 13:11
Disable.fields blocks the field for all the rows if it is used in multioccurence session .
However after mentioning the field in function disable.fields if occurence is specified(e.g. disable.fields(READONLY,"tdgbb010.item",actual.occ) then disable.fields blocks only field for that particular occurence .
Since this was not specified anywhere in this topic I thought I can share this point .