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)
Auto-Fill a Date Field
rpjoseph
I would like to drop the current date on an item in datacapture.cfg. The following script is in an initialize function called by my cfg file:
if ( IWDatacapture.getItem( "/Date" ).getValue() == null
|| IWDatacapture.getItem( "/Date" ).getValue() == "" )
{
IWDatacapture.getItem( "/Date" ).setValue( getDate( 0 ));
}
Here is the getDate function:
function getDate( number )
{
today = new Date();
today.setDate( today.getDate() + number );
return(( today.getMonth() + 1 ) + "/" + today.getDate() + "/" + today.getYear());
}
Here is the section in my datacapture.cfg file that I am trying to affect:
<item name="Date">
<description>Specify the date to associate with the press release.</description>
<label>Date (MM/DD/YYYY)</label>
<text required="t" validation-regex="^[0-1]?[0-9]/[0-3]?[0-9]/[0-9]{4}$" maxlength="10">
</text>
</item>
The field is blank. Does anybody see what I am doing wrong or have a better idea? Thank you
Find more posts tagged with
Comments
mgal
Did you try using inline callout?
Jens
I have tested your code and it works fine.
So the code seems to be ok.
Did you checked, if your init-function is called correctly?
rpjoseph
Thank you. I am sorry for the bother. There was an error in my init function. Once it was resolved my date showed up. Thank you for the help.