Remove field with Null on email

Good Day

I would like to remove a field from an email if the variable value is Null/“Not Set”.

In the below example Pattern has no value but I still see it on the email.

Here is my code in HTML:

Subject: AutoReply: {$Ticket->Subject}
Content-Type: text/html

<p>Greetings,</p>

<p>An incident has been created with regard to <b>{$Ticket->Subject()}</b>.</p>


<hr/>

<table border="0">
<tr><td align="right"><b>Transaction:</b></td><td>{$Transaction->Description}</td></tr>
<tr><td align="right"><b>Queue:</b></td><td>{$Ticket->QueueObj->Name}</td></tr>
<tr><td align="right"><b>Subject:</b></td><td>{$Transaction->Subject || $Ticket->Subject || "(No subject given)"} </td></tr>
<tr><td align="right"><b>Owner:</b></td><td>{$Ticket->OwnerObj->Name}</td></tr>
<tr><td align="right"><b>Requestors:</b></td><td>{$Ticket->RequestorAddresses}</td></tr>
<tr><td align="right"><b>Subject:</b></td><td>{$Transaction->Subject || $Ticket->Subject || "(No subject given)"} </td></tr>
<tr><td align="right"><b>Status:</b></td><td>{$Ticket->Status}</td></tr>
<tr><td align="right"><b>Severity:</b></td><td>{$Ticket->FirstCustomFieldValue('Severity')}</td></tr>
<tr><td align="right"><b>Domain:</b></td><td>{$Ticket->FirstCustomFieldValue('Domain')}</td></tr>
<tr><td align="right"><b>Service Element:</b></td><td>{$Ticket->FirstCustomFieldValue('Service Elements')}</td></tr>
<tr><td align="right"><b>Actual Error:</b></td><td>{$Ticket->FirstCustomFieldValue('Actual Error')}</td></tr>
<tr><td align="right"><b>Pattern:</b></td><td>{$Ticket->FirstCustomFieldValue('Pattern')}</td></tr>

</table>
<br/>

image

You could use a Perl conditional for that line. Something like:

{ ($Ticket->FirstCustomFieldValue('Pattern')) ? "<tr><td align='right'><b>Pattern:</b></td><td>".$Ticket->FirstCustomFieldValue('Pattern')."</td></tr>\n" : "" }

See if that helps.

Thank you very much :grinning::grinning::grinning::smile::smile::smile::smile:

It works like a charm !!!