push @results, $msg;
warn "$me: linking requestor to custnum $custnum: $msg\n"
if $Debug > 1;
+
+ ## check if FS contact email exists, if not create it.
+ if ( !qsearchs( {
+ 'table' => 'contact_email',
+ 'hashref' => { 'emailaddress' => $Requestor->{'values'}->{'emailaddress'}, },
+ } ) ) {
+ use FS::contact;
+
+ my $lname = $Requestor->{'values'}->{'realname'} ?
+ (split (/ /, $Requestor->{'values'}->{'realname'}))[-1] :
+ 'Requestor';
+
+ my $fname = $Requestor->{'values'}->{'realname'} ?
+ (split (/ /, $Requestor->{'values'}->{'realname'}))[0] :
+ 'RT';
+
+ my $contact = new FS::contact {
+ 'custnum' => $custnum,
+ 'first' => $fname,
+ 'last' => $lname,
+ 'emailaddress' => $Requestor->{'values'}->{'emailaddress'},
+ 'comment' => 'Auto created from RT requestor',
+ };
+ my $error = $contact->insert;
+ push @results, 'Created Freeside contact for requestor ' . $Requestor->{'values'}->{'emailaddress'}
+ unless $error;
+ }
}
}
my $value = shift;
my %args = ( Arguments => [],
Escape => 1,
- FormatDate => \&default_FormatDate,
@_ );
+ my $FormatDate = $m->notes('FormatDate') || \&default_FormatDate;
+
if ( ref $value ) {
if ( ref $value eq 'RT::Date' ) {
- return $args{FormatDate}->($value);
+ return $FormatDate->($value);
} elsif ( UNIVERSAL::isa( $value, 'CODE' ) ) {
my @tmp = $value->( @{ $args{'Arguments'} } );
return ProcessColumnMapValue( ( @tmp > 1 ? \@tmp : $tmp[0] ), %args );