HelpSpot Help Desk Software | HelpSpot Blog | HelpSpot Support

How to create a Salutation from a Custom Field?


#1

Hi there,
my LL works proper!
In my Livelookup i receive the GENDER … it M (MALE) or F(FEMALE)
Now i like to generate the Salutation “geehrter Herr” if GENDER= MALE and “geehrte Frau” if GENDER=FEMALE

This due to that we like to reply to our Customers personalized!
So our replies lookk like:
Sehr ##custom6## ##last_name##,

bla bla

But i receive only M or F from my LL!
So i must translate the received GENDER like:
If GENDER = M then custom6="geehrter Herr"
else
if GENDER=F then custom6=“geehrte Frau”

BUT HOW and WHERE to do?

thanks for Answer
ralf


#2

So in the data source you query you mean you get back M/F right? OK so in the XML probably at the bottom of the LL script you’d put the logic. It depends on your exact script but you’d add in something like:

‘’.($data[‘gender’] == ‘M’ ? “geehrter Herr” : “geehrte Frau”).’’


#3

thx great! i’ve tried … but have to ask my developer :wink: no result…
my script:

<?php while($row = mysql_fetch_assoc($result)): ?>

<customer_id><?php echo $row['ID'] ?></customer_id>
<first_name><?php echo $row['Vorname'] ?></first_name>
<last_name><?php echo $row['Name'] ?></last_name>
<?php echo $row['Gender'] ?>
<?php echo $row['Geburtsdatum'] ?>
<?php echo $row['EMail'] ?>
<?php echo $row['Strasse'] ?>
<?php echo $row['PLZ'] ?>
<?php echo $row['Ort'] ?>
<?php echo $row['KTO'] ?>
<?php echo $row['BLZ'] ?>
<Support_Tool>

<![CDATA[ <?php echo ''.$row['ID'].'' ?> ]]>

</Support_Tool>

’. $data[‘Gender’] == ‘M’ ? “geehrter Herr” : “geehrte Frau”.’
<?php endwhile; ?>

Insert of Customer_ID works well …but the result of ##custom27 =’. $data[‘Gender’] == ‘M’ ? “geehrter Herr” : “geehrte Frau”.’

ralf


#4

OK just 2 changes I think should fix it.

#1 - Move the tag inside the closing tag, right now it’s past it.

#2 - the line should be:
<?php echo ($data['Gender'] == 'M' ? "geehrter Herr" : "geehrte Frau") ?>


#5

$DATA is wrong!

This is correct:
<?php if ($row['Gender'] == 'M') echo "geehrter Herr"; elseif ($row['Gender'] == 'F') echo "geehrte Frau"; else echo "ERROR"; ?>

need row instead of data
Now it works well,
thanks for your help.

regards
Ralf


#6

oh yep, nice catch! Excellent.