When I use <OTRS_CUSTOMER_REALNAME> in a salutation and the customer name is unknown, the name part is derived from the e-mail address. (eg. Dear Help,).
This is expected behavior which I hoped would be the same when using other variables.
But now I tried to replace it with <OTRS_CUSTOMER_UserFirstname>.
OTRS_CUSTOMER_UserFirstname is mapped from LDAP in Kernel/Config.pm
$mapping{'dev'} = [
# note: Login, Email and CustomerID needed!
# var, frontend, storage, shown (1=always,2=lite), required, storage-type, http-link, readonly, http-link-target
[ 'UserName', 'Name (LDAP)', 'cn', 1, 1, 'var' ],
[ 'UserLogin', 'Useradmin', 'uid', 1, 1, 'var' ],
[ 'UserEmail', 'Email', 'mail', 1, 1, 'var' ],
[ 'UserCustomerID', 'CustomerID', 'mail', 0, 1, 'var' ],
[ 'UserFirstname', 'Firstname', 'preferredGivenName', 1, 0, 'var' ],
[ 'UserComment', 'Forw', 'mailforwardingaddress', 1, 0, 'var' ],
];
It works like a charm when the customer can be found in LDAP.
However, if the user is not in LDAP, a - is displayed. (eg. Dear -,).
How do I get OTRS to return a name derived from the e-mail address (or simply nothing) when the first name of the customer is not known in LDAP?
OTRS_CUSTOMER_UserFirstname equals - when customer is not in LDAP
Moderator: crythias
OTRS_CUSTOMER_UserFirstname equals - when customer is not in LDAP
OTRS 6.0.x (private/testing) on Linux with MySQL database.
Re: OTRS_CUSTOMER_UserFirstname equals - when customer is not in LDAP
Any thoughts on this?
OTRS 6.0.x (private/testing) on Linux with MySQL database.
Re: OTRS_CUSTOMER_UserFirstname equals - when customer is not in LDAP
I am no longer retrieving the customer first name from LDAP because it would default to - if the user is not known in LDAP.
I was able to create my own solution by adding a new OTRS_CUSTOMER_FIRSTNAME template variable to Kernel/System/TemplateGenerator.pm that tries to get the first name from the e-mail address.
Added the code below at line 1941
Just putting it out there in case someone can use it.
I will not be able to provide any support on this.
I was able to create my own solution by adding a new OTRS_CUSTOMER_FIRSTNAME template variable to Kernel/System/TemplateGenerator.pm that tries to get the first name from the e-mail address.
Added the code below at line 1941
Code: Select all
# get and prepare firstname
$Tag = $Start . 'OTRS_CUSTOMER_FIRSTNAME';
if ( $Param{Text} =~ /$Tag$End/i ) {
my $From;
if ( $Ticket{CustomerUserID} ) {
$From = $CustomerUserObject->CustomerName(
UserLogin => $Ticket{CustomerUserID}
);
}
# try to get the real name directly from the data
$From //= $Recipient{Realname};
# get real name based on reply-to
if ( !$From && $Data{ReplyTo} ) {
$From = $Data{ReplyTo};
# remove email addresses
$From =~ s/<.*>|<.*>|\(.*\)|\"|"|;|,//g;
# remove leading/trailing spaces
$From =~ s/^\s+//g;
$From =~ s/\s+$//g;
}
# generate real name based on sender line
if ( !$From ) {
$From = $Data{To} || '';
# remove email addresses
$From =~ s/<.*>|<.*>|\(.*\)|\"|"|;|,//g;
# remove leading/trailing spaces
$From =~ s/^\s+//g;
$From =~ s/\s+$//g;
}
# remove lastname to end up with firstname only
$From =~ s/\s+.*$//g;
# replace <OTRS_CUSTOMER_FIRSTNAME> with from
$Param{Text} =~ s/$Tag$End/$From/g;
}
I will not be able to provide any support on this.
OTRS 6.0.x (private/testing) on Linux with MySQL database.