Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Variable error messages in Tag_info
nugget_shark
Could use some help!
Trying to set variable error messages in the error_msg property of a Tag_info section...but not getting the results that I expect...
Basically passing the results of an prompt for date to a subroutine that checks for various conditions and based on the conditions
I want to have different error messages returned...
Has anyone done anything like this before?
Thanks in advance for the help...
Find more posts tagged with
Comments
Adam Stoller
It would probably help if you showed the code - just the TAG_info() portion and the subroutine (if any) called from it.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
nugget_shark
Following is a snippet of the code...
TAG_info(
task_due_date => [
html => "$pickdate",
label=> "Publication Date (YYYY-MM-DD)",
valid_input => 'checkDate($_)',
#error_msg => "Please enter a publication date in the format YYYY-MM-DD",
error_msg => "$errmsg",
is_required => "false",
],
and here's the routine to check the date... the $pickdate is html that includes a call to a calendar function...
would like to be able to return variable error messages to error_msg based on certain conditions (incorrect
date, publish date < today's date, etc...)
sub checkDate {
printLog("parms are " . (join "|",
@_))
;
my ($t_due_date) =
@_
;
printLog("published_date initially = $t_due_date");
my($published_date) = '';
# my $errmsg = "Please enter value in MM/DD/YYYY format";
if (defined($t_due_date) && $t_due_date != '') {
$published_date = ParseDate($t_due_date);
printLog("published_date = $published_date");
if (!$published_date) {
$errmsg = "Please enter value in YYYYMMDD format";
return 0 ;
}
}
# we have two dates - now compare them
if ($published_date != ''){
my $published_date_yyyy_mm_dd = substr($published_date, 0, 8);
my $todays_date = ParseDate("today");
my $todays_date_yyyy_mm_dd = substr($todays_date, 0, 8);
printLog("published_date_yyyy_mm_dd = $published_date_yyyy_mm_dd");
printLog("todays_date_yyyy_mm_dd = $todays_date_yyyy_mm_dd");
my $date_check_flag = Date_Cmp($published_date_yyyy_mm_dd, $todays_date_yyyy_mm_dd);
printLog("date_check_flag = $date_check_flag");
if ($date_check_flag < 0) {
# Published date is earlier than today
return 0;
return "Published Date, '$published_date', cannot be before Today's date";
}
else {
# Published date is earlier than today
return 1;
}
}
# if we somehow made it this far, assume success?
return 1;
}
Parameter.rptdesign
jbonifaci
If you want to have a custom error message, I would suggest using javascript to validate the form before letting the user submit it.
~Jeff
Adam Stoller
I'd suggest doing something like this:
...
task_due_date => [
html => "$pickdate",
label=> "Publication Date (YYYY-MM-DD)",
valid_input =>
"
checkDate($_
, 0
)
"
,
#error_msg => "Please enter a publication date in the format YYYY-MM-DD",
error_msg => "
checkDate($_, 1)
",
is_required => "false",
],
...
(I believe you need double-quotes around the directive for calling the suroutine so that the '$_' is interpolated)
The second paramater to checkDate would be:
0
boolean return value
, or
1
string return value
- then modify your checkDate function to check the second paramater - and anyplace where you are returning a value - do something like:
sub checkDate{
my($t_due_date,
$send_msg
) =
@_
;
...
if (!$published_date) {
return (
$send_msg
) ? "Please enter value in YYYYMMDD format" : 0;
}
...
...
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
nugget_shark
good idea!!!
thanks much!!!
brandon1
If you want to have a custom error message, I would suggest using javascript to validate the form before letting the user submit it.
I have painfully found out that the way the iwwft_instantiator is invoked via the "wizard" (tt_data) functionality is different than the "submit" functionality. So a javascript that works via submit is not easily fireable via the way wizard invokes the iwwft_instaniator.
Brandon
Current Project: TS 6.1
Environment: Windows