/
sendEmail() Template Throws Error, "Variable >>issue<< is already defined in the same context!"

sendEmail() Template Throws Error, "Variable >>issue<< is already defined in the same context!"

Problem

When referencing the ā€œissueā€ variable in a template referenced when using sendEmail(), an error is thrown "Variable >>issue<< is already defined in the same context!"

The ā€œissueā€ variable is a reserved keyword when using sendmail() with a template. Consider the following sendEmail() script that references ā€œtemplate.tplā€:

string issue = "DEMO-1"; sendEmail("name@example.com", "subject goes here, "path/to/template.tpl");

Now for template.tpl:

Current issue key: $issue$.

Solution

Consider using a variable besides ā€œissueā€. For example, ā€œissueKeyā€:

string issueKey = "DEMO-1"; sendEmail("name@example.com", "subject goes here, "path/to/template.tpl");

Now for template.tpl:

Current issue key: $issueKey$.

In this instance, ā€œissueKeyā€ will not throw an error.

Related articles

Filter by label

There are no items with the selected labels at this time.

Related content