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)
capture system date in dcr
vinylrecord
Can anyone plz help me out with this..
How can i write a datacapture.cfg that takes the system date by default.That is when a new data record is created, then the current date field displays the default system date.
Is is possible then how?
Thanks in anticipation.
Find more posts tagged with
Comments
Jeremy
If you do a search for "system" and "date" in templating you'll find that this topic has been discussed a few times.
Migrateduser
I've seen this work:
//----------------------------------------------------------------------
// Return a string representing today's date plus the specified number
// of days (0 to get today). Used to default values without
// relatively expensive inline calls.
//----------------------------------------------------------------------
function getDate( number )
{
today = new Date();
today.setDate( today.getDate() + number );
return(( today.getMonth() + 1 ) + "/" + today.getDate() + "/" + today.getYear());
}
if ( IWDatacapture.getItem( "/SomeDate" ).getValue() == "" )
{
IWDatacapture.getItem( "/SomeDate" ).setValue( getDate( 0 ));
}
IWDatacapture.getItem( "/SomeDate" ).setReadOnly( true );
as well as you can create an lin_line perl script which pulls your date directly from whatever database you are using?
something like this:
#!D:\iw-home/iw-perl/bin/iwperl.exe
###################################################################
#
# inline_get_date.ipl
#
# Server-side inline data capture callout program that queries an Oracle db
# and returns date
# Usage:
# inline_get_date.ipl
#
####################################################################
BEGIN {
$ENV {ORACLE_HOME} = 'D:\oracle\ora81';
$ENV {Path} = 'D:\oracle\ora81\bin;
$ENV {SystemRoot} = 'C:\WINNT';
}
############################## Modules #############################
use DBI;
use strict;
########################## Global variables ########################
my $XML_HEADER; # the XML header that returns to the DCT
my $XML_FOOTER; # the XML footer that returns to the DCT
##################### Set the values of variables ####################
$XML_HEADER="<?xml version='1.0' encoding='UTF-8'?><substitution><text required='t' maxlength='8'><default>";
$XML_FOOTER="</default></text></substitution>";
##################### Call the main Subroutine ####################
&main();
########################## Main Subroutine ########################
# this is the entry point of the program, it calls the other two
# subroutines
sub main{
######################## LOCAL VARIABLES ######################
my $valuearrayref1; # a reference to the option list values
my $valuearrayref2; # a reference to the option list labels
my $optionstring; # the option string
###############################################################
($valuearrayref1,$valuearrayref2) = &get_fieldvalues();
$optionstring = &get_optionstring($valuearrayref1, $valuearrayref2);
print "$XML_HEADER";
print "$optionstring";
print "$XML_FOOTER";
return 0;
}
##################### get Option String Subroutine ###################
# This subroutine creates the Option String and it will return the HTML
# to main subroutine
sub get_fieldvalues{
######################## LOCAL VARIABLES ######################
my $db; # set up for the database connection
my $query; # DB select statement to association table
my $sth; # the statement handle
my $name; # the product name that selected from the table
my $tmp; #tmp var for & to &
my
@row
; # the array that contains the values
my
@row1
; # the array that contains the column key (ISBN)
my
@row2
; # the array that contains the column value (name)
my $dsn; # the data source
my $db_user_name; # the database username
my $db_password; # the database password
my $table_name; # the table name
my $column_key; # the column key (ISBN)
my $column_value; # the column value (name)
$dsn = "yourdsnname";
$db_user_name = "yourusername";
$db_password = "yourpassword";
$table_name = "dual";
$column_key = "to_char(SYSDATE, 'MM/DD/YYYY')";
$column_value = "to_char(SYSDATE, 'MM/DD/YYYY')";
# Connect to the database
$db = DBI->connect("dbi
DBC:$dsn", "$db_user_name", "$db_password")
or die "Unable to open database connection $!";
# the database query statement
$query = "SELECT " . $column_key. "," . $column_value . " FROM " . $table_name;
# Prepare and execute the statement
$sth = $db->prepare("$query");
$sth->execute() or die "$!";
# Get the current data and put it to the arrays
while (
@row=$sth->
;fetchrow()) {
$tmp = $row[0];
$tmp =~ s/&/&/;
push(
@row1
,$tmp);
$tmp = $row[1];
$tmp =~ s/&/&/;
push(
@row2
,$tmp);
}
$sth->finish;
$db->disconnect || die "Error Closing the Database\n";
return (\
@row1
,\
@row2)
;
}
##################### get Field Value Subroutine ###################
# This subroutine creates the option list string filled with the
# necessary values from the database that has been passed as an argument
#
# the argument:
# $arrayreference - the array reference that passed as an argument
# and used to generate the option list string
sub get_optionstring{
######################## LOCAL VARIABLES ######################
my $array_ref1; # the array reference to key
my $array_ref2; # the array reference to value
my $option_string; # the option list string
my $idx; # the index of the array
$array_ref1 = shift;
$array_ref2 = shift;
# get the array value and append it to the option string
for ($idx = 0; $idx <= $#{ $array_ref1 }; $idx++) {
#$option_string .= "<text label=\"$array_ref2->[$idx]\" value=\"$array_ref1->[$idx]\"/>\n";
$option_string .= "$array_ref2->[$idx]";
}
return ($option_string);
}