#!/usr/bin/perl
#
## NAME: change_addfields.pl
#
## DESC: This trigger adds extra field entry items within the "Description:" field
# to customize the change form.
#
# Triggers:
# change_submit_template form-out change "/home/user/triggers/change_addfields.pl %formtype% %formfile%"
#
my $p4 = "p4 -p localhost:1666";
my $formtype = $ARGV[0]; # from %formtype% in trigger table
my $formfile = $ARGV[1]; # from %formfile% in trigger table
$defaultin = "<enter description here>";
$addflds = "\n\tBugs: <enter bugs here>\n\tStatus: <enter bug status here>\n\tModified By: <enter user name who did modifications>\n";
open (LOGFILE, ">/tmp/triggeroutput");
my $modifiedform = "";
open (FORM, "$formfile") || print LOGFILE "Trigger couldn't read form tempfile\n";
while ( <FORM> )
{ ## Do the substitution as appropriate.
if ( m:$defaultin: ) { $_ .= $addflds; }
$modifiedform .= $_;
}
print LOGFILE $modifiedform;
open (MODFORM, ">$formfile") || die "Couldn't write form tempfile";
print MODFORM $modifiedform;
close LOGFILE;
exit 0;