Same need and seem to have figured it out
I'm using osTicket 1.6 ST, so I'm not sure whether this will work in newer versions but it seems to be fine in 1.6ST. In my case I added a location field to my tickets so support personnel knew where to respond to. I found steps at (http://osticket.com/forums/showthread.php?t=873&highlight=custom+field+email&page=4), but from what I could tell it didn't change all the email templates, so instead I came up with this way instead.
I'm going to assume you added a custom field using the steps found in this thread: (http://osticket.com/forums/showthread.php?t=873&highlight=custom+field+email). If not, you may have to tweak this slightly. The main part you need is the getNewvar() function, which gets added in the following code from the original thread for adding a custom field:
//GET
function getId(){
return $this->id;
}
function getExtId(){
return $this->extid;
}
function getEmail(){
return $this->email;
}
function getNewvar(){
return $this->newvar;
}
If you have this then you're set. You have to change the include/class.ticket.php file. Open it with your favorite text editor and find the following code (approximately line 424)
function replaceTemplateVars($text){
global $cfg;
$dept = $this->getDept();
$staff= $this->getStaff();
$search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/',
'/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/');
$replace = array($this->getId(),
$this->getExtId(),
$this->getEmail(),
$this->getName(),
$this->getSubject(),
$this->getHelpTopic(),
$this->getPhoneNumber(),
$this->getStatus(),
$this->getPriority(),
($dept?$dept->getName():''),
($staff?$staff->getName():''),
Format:($this->getCreateDate()),
Format:($this->getDueDate()),
Format:($this->getCloseDate()),
$cfg->getBaseUrl());
return preg_replace($search,$replace,$text);
}
This is the function responsible for replacing the variable placeholders within the email template. Pretending like we added a field named newvar to the form, and also created getNewvar(), here's what you'd change the code to in order to use %newvar within an email
function replaceTemplateVars($text){
global $cfg;
$dept = $this->getDept();
$staff= $this->getStaff();
$search = array('/%id/','/%ticket/','/%email/','/%name/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/',
'/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/','/%newvar/');
$replace = array($this->getId(),
$this->getExtId(),
$this->getEmail(),
$this->getName(),
$this->getSubject(),
$this->getHelpTopic(),
$this->getPhoneNumber(),
$this->getStatus(),
$this->getPriority(),
($dept?$dept->getName():''),
($staff?$staff->getName():''),
Format:($this->getCreateDate()),
Format:($this->getDueDate()),
Format:($this->getCloseDate()),
$cfg->getBaseUrl(),
$this->getNewvar());
return preg_replace($search,$replace,$text);
}
Make sure to move the second right-hand parantheses from getBaseUrl() to the new line since it encloses the entire array. After you save this you should be able to use %newvar in the email templates and have it dynamically populate itself. Go ahead and change 'newvar' to whatever your field is named and it should work for you.