New operation notification template for Requester User
In the following example, we are going to configure an email template.
This template will be used to notify the Requester about the creation of a new operation.
STEP 1 – TEMPLATE IDENTIFICATION FIELDS
Fill in the template identificative fields:
- Name (ex: ‘REQUESTER – OPERATION Created’)
- Code (ex: ’email_to_requester_operation_created’)
- Status: Enabled
STEP 2 – CONFIGURE THE EMAIL SUBJECT LINE
In the scripting area ‘Subject‘ insert the following PHP code
__('Ticket with ID')?>
getPrefix().$this->getModel()->getId()?>
__('sent')?>
The resulting subject will be like: “Ticket with ID TICKET#101 sent”.
STEP 3 – CONFIGURE THE EMAIL BODY
In the Body scripting area enter the following PHP code
getModel() returns the current service operation instance
$operation = $this->getModel();
//$operation->getRequesterUser() loads the requester user object if he is registered
$requesterUser = $operation->getRequesterUser();
//test if requester is a registered user
$requesterIsRegistered = $requesterUser && $requesterUser->getId();
//if requester is registered then use getDisplayUsername() that returns 'Firstname Lastname'
//if the requester is not a registered user use the value of the service operation field requester_username
$requesterUsername = $requesterIsRegistered ? $requesterUser->getDisplayUsername() : $operation->getRequesterUsername();
?>
includeTemplate("header") ?>
__('Dear') . ' ' . $requesterUsername ?>,
getPortalUrl() ?>
__('Ticket with ID')?>
getId()?>
getId()?>
__('has been received by our support')?>
__('Title')?>:
getTitle()?>
__('Description')?>:
getDescription()?>
__('Requester User')?>:
getAvatar()):?>
getUrgencyId()):?>
__('Urgency')?>:
loadList(
Deep_Service_Model_Operation::LIST_CODE_URGENCY
);
//get the corrisponding Urgency label
$urgencyValue = $urgencyList->getValue($operation->getUrgencyId()); ?>
__($urgencyValue->getValueLabel()); ?>
__('Go to the Ticket')?>
includeTemplate("footer") ?>
The email notification body will look like the image below.
