alerts
16th December 2013, 09:56
Hi,
I am facing problem when making text field to be mandatory field. i have written code in check.input section but after writing data into text field, its showing zero at check.input section. So its firing customized error message that the relevant field is empty, even though its data is present. Please suggest me any way to resolve this problem.
Thanks and Regards,
bhushanchanda
16th December 2013, 11:13
Hi,
Try writing your code in after.input: section.
field.field_name:
after.input:
if isspace(field_name) then
message("This field is mandatory!")
input.again()
endif
Refer this:- thread (http://www.baanboard.com/baanboard/showthread.php?p=185451)
alerts
16th December 2013, 11:54
since it is the text field after saving the text, the corresponding number get generated and stored in the text field, but we are checking before save, even though we enter text , its getting zero while checking. while zero means there is no text but text is present.
bhushanchanda
16th December 2013, 11:57
Hi,
Please post your script. That will help others to understand the issue better.
alerts
16th December 2013, 12:16
field.whaal023.actt:
check.input:
if whaal023.accg = tcyesno.yes then
if whaal023.actt = 0 then
message("Action Taken Is Mandatory")
set.input.error("",e)
endif
endif
i wrote above code to make it mandatory , it is mandatory only if whaal023.accg field is yes, if proceeding without entering the text field its showing error, which is requirement also but after entering text also its showing error message which is matter of concern.
bhushanchanda
16th December 2013, 12:39
Ahh,
Its a text field.
Well, just create a DAL script for your main table and do this:-
#include <bic_dal2>
#include <bic_dam>
string err.msg(50)
table ttcbed006 | My Test Table
function extern long before.open.object.set()
{
return(0)
}
function extern long before.save.object(long mode)
{
if tcbed006.text = 0 then | My Text field
err.msg = "Not Allowed!"
dal.set.error.message("tigenstring",err.msg)
return(DALHOOKERROR)
endif
return(0)
}
bhushanchanda
16th December 2013, 13:32
Also,
There is one more way to do it, but it will give you system/ database error messages too.
Try it:-
main.table.io:
before.write:
if tcbed006.text = 0 then
message("Not Allowed!")
tcbed006.item = "" | If the field is blank, clear your index field of that table, hence insert action will be stopped!
endif
before.rewrite:
if tcbed006.text = 0 then
message("Not Allowed!")
tcbed006.item = "" | If user tries to empty it after the record is saved, again, clear the index field. . It will give the system error and record wont be saved.
endif
Well, but always prefer to use DAL when possible!
benito
16th December 2013, 17:07
have you tried "when.field.changes" with "input.again" if it fails?
bhushanchanda
16th December 2013, 21:15
have you tried "when.field.changes" with "input.again" if it fails?
No, it doesn't work with text field. And, if the field is left blank and saved, this section will never be called.
The best way to do it is with DAL, because, the text field updates table tttxt010 first and then the main table. Hence, the field sections , check.input sections wont do it. main.table.io: sections captures the conditions, but until you block the trasaction, its too late as the other table will be updated.
So, as already mentioned, if on LN, go for DAL.
alerts
17th December 2013, 09:25
Thank you very much, its done using DAL.
Thanks and Regards,
bhushanchanda
17th December 2013, 10:24
Good.
So, one more significance of DAL :)