Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
how to implement date comparison
hpp
TAG_info( writeDate => [ html => get_calender("writeDate"), label => "...", is_required => 'true', error_msg => "enter the date dd/mm/yyyy"), ],
reviewDate => [ html => get_calender("reviewDate"), label => "...", is_required =>'true', error_msg => checkDate(__VALUE__(reviewDate), $_, 1), ],
submit => [html => "<input type='submit' >", is_required => 'false', label => "submit",], );
in the workflow1.wft file how can I comapre these two dates and if reviewdate > writedate it display message " review date should not be greater than the writedate".
Find more posts tagged with
Comments
saumil
Hi,
Try Following.......
TAG_info( writeDate => [ html => get_calender("writeDate"), label => "...", is_required => 'true', error_msg => "enter the date dd/mm/yyyy"), ],
reviewDate => [ html => get_calender("reviewDate"), label => "...", is_required =>'true', error_msg => checkDate(__VALUE__(reviewDate), $_, 1), ],
submit => [html => "[input type='submit' ]",
valid_input => validate
,is_required => 'false', label => "submit",], );
sub validate(){
#code for checking your validation criteria
}
Saumil
BV/BEA (BT.COM) | CMS
hpp
In workflow wft file my code is like this:
its not showing any errors,its creating job also fine.
here the the validations are not checking for this shall add anything more to validate
my $fdate = __VALUE__('fdate');
my $tdate = __VALUE__('tdate');
my $submit = __VALUE__('submit');
TAG_info(
fdate => [html => "<input type='text' value=''>",
is_required => 'true',
label => "fdate",
error_msg => 'enter dd/mm/yyyy format',],
tdate => [html => "<input type='text' value='12/12/2003'>",
is_required => 'true',
label => "tdate",
valid_input => checkDate(__VALUE__(fromDate), $_ , 0),
error_msg => checkDate(__VALUE__(fromDate), $_ , 1),],
submit => [html => "<input type='submit' value='submit' valid_input => validate,is_required => 'false', label => "submit",],
);
my $Output1="C:/iw-home/httpd/iw-bin/niccc/T1.txt";
open OUT, ">$Output1" or die "Cannot open $Output1 for write :$!";
print OUT "hymakkkkkkkkkkkkkkkk";
sub checkDate {
print OUT "HH1\n";
my($fromDate, $toDate, $errmsg) =
@_
;
my($fd, $td) = ('','');
# handle each date separately
if (defined($fromDate) && $fromDate ne '')
{
print OUT "HH11\n";
$fd = ParseDate($fromDate);
print OUT "XXXXXXXXXXXXXXXXXX=$fd";
if (!$fd) {
return 0 if (!$errmsg);
return "'$fromDate' is not valid - please enter value in MM/DD/YYYY format";
}
}
if (defined($toDate) && $toDate ne '')
{
print OUT "HH111\n";
$td = ParseDate($toDate);
if (!$fd){
return 0 if (!$errmsg);
return "'$toDate' is not valid - please enter value in MM/DD/YYYY format";
}
}
# we have two dates - now compare them
if ($td ne '' && $fd ne '')
{
print OUT "HH12\n";
my $flag = Date_Cmp($fd, $td);
if ($flag < 0)
{
return 1;
print OUT "HH111111111\n";
}
elsif ($flag == 0)
{
print OUT "HH133333333\n";
# fd is the same as td
return 0 if (!$errmsg);
return "Write by and Review by dates cannot be the same";
print OUT "flag == 0\n";
}
else
{
print OUT "HH1555\n";
# fd is later than td
return 0 if (!$errmsg);
return "Write by date cannot be after Review by date";
}
}
print OUT "HH188888\n";
# if we somehow made it this far, assume success? return 1;
}
thanks
hpp
Adam Stoller
(
reformatted for clarity
)
TAG_info(
fdate
=> [
html => "<input type='text' value=''>",
is_required => 'true',
label => "fdate",
error_msg => 'enter dd/mm/yyyy format',
],
tdate => [
html => "<input type='text' value='12/12/2003'>",
is_required => 'true',
label => "tdate",
valid_input => checkDate(__VALUE__(
fromDate
), $_ , 0),
error_msg => checkDate(__VALUE__(
fromDate
), $_ , 1),
],
submit => [
...
],
);
You either need to change
fdate
to
fromDate
or vice versa.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
saumil
Hi,
Hopefully Fish has been resolve your problem.
I can suggest you one more thing.
Instead of calling function in
error_msg
, use variable and set variable by error Message in to your subroutine.
Correct me If I am making mistake.
Saumil
BV/BEA (BT.COM) | CMS
sanjeevappa
Hi ,,
I think this has been discussed just a day back, just go and search in work flow section.
Fish has answered with complete code, just see that
(FYI)
Before posting try to search in DevNet first.
San.