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)
date comparison in metadata
Ebe
I am trying to write a comparison of two dates in a metadata capture form. One date has to be later than the other (i.e. the date of expiry needs to be later than the deployment date and this needs to be checked in the metadata input form.) The code for the dates is included below.
<item name="rightsPermissionsDeploymentIndendedDateOfDeployment">
<label>Intended date of availability (dd-MM-yyyy)</label>
<database data-type="DATE" data-format="dd-MM-yyyy" />
<text required="t" maxlength="10" size="10" validation-regex="^[0-3][0-9]-[0-1][0-9]-[0-2][0-9][0-9][0-9]$" />
</item>
<item name="rightsPermissionsDeploymentDateOfExpiry">
<label>Date of expiry (dd-MM-yyyy)</label>
<database data-type="DATE" data-format="dd-MM-yyyy" />
<text required="t" maxlength="10" size="10" validation-regex="^[0-3][0-9]-[0-1][0-9]-[0-2][0-9][0-9][0-9]$" />
</item>
I think my validation-regex is ok, but if this is also wrong please let me know. I would be inordinately grateful if someone had the comparison code and was willing to share.
Thank you,
Ebe
Find more posts tagged with
Comments
Adam Stoller
Unfortunately, metadata capture DCTs do not provide for FormAPI code - so the only way to provide cross-field validation in metadata capture is through a cgi-callout script that pulls in the various values from the various fields and performs that comparison for you -- and with that sets a unique (perhaps hidded-but-required) field to indicate whether or not the test(s) pass so as to let the UI know whether or not to allow the saving of the metadata.
The code for the cgi-callout depends on what version of TeamSite you're running -- if it's PRE-6.x and you do *not* have MetaTagger installed - you can use some pretty basic javascript code to go through and pull out the values of the form field-name by field name. If it's 6.x - you'll have to wait for a patch / service pack in which they make it possible to do that - or you have to write your own mapping algorithm code that figures out the relationship of fields to fields because in 6.x / MetaTagger GUI - all the form field names (other than the one directly associated with the cgi-callout) are represented as "propxxxxx" [where x is a numerical character - e.g. prop138434].
The validation-regex's you used are pretty basic and allow bad dates to be accepted (e.g. 00-00-0000 or 39-19-2999 are both acceptable to your regex) - you might want to take a look at
http://devnet.interwoven.com/site.fcgi/techlib/045818
for a more accurate validation-regex for dates.
Code for comparing two dates in javascript can most likely be found on the www - just google for it if you're not comfortable writing your own.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com