diff options
author | Christopher Burger <burgerc@freeside.biz> | 2017-07-20 09:29:45 -0400 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2017-07-25 08:41:55 -0400 |
commit | 44c03de388473659249249885c8b068485ec4112 (patch) | |
tree | 7da3a361b6fed625e3f021054ed7f6ceaaf095be | |
parent | dec15062e2df6f615e42d5f87193133a3e072826 (diff) |
RT# 38517 - added auto create of customer contact, if requestor is not a contact yet when adding a company to ticket.
-rw-r--r-- | rt/lib/RT/Interface/Web_Vendor.pm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/rt/lib/RT/Interface/Web_Vendor.pm b/rt/lib/RT/Interface/Web_Vendor.pm index c9bff6f36..b9f27a436 100644 --- a/rt/lib/RT/Interface/Web_Vendor.pm +++ b/rt/lib/RT/Interface/Web_Vendor.pm @@ -164,6 +164,33 @@ sub ProcessTicketCustomers { 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; + } } } |