Dynamically set a created issues priority from a header
Here the related issue value is set to a TemplateIssue should the email be a reply and refer (or indirectly refer) to an existing issue. The example only sets the priority on create.
if (relatedIssue)
{
print('not updating an existing issue: '+relatedIssue.getKey());
}
else
{
print('no relatedIssue found, creating an issue, checking for custom priority via header');
var priority = message.getHeader("X-Priority");
if (priority)
{
print('found priority[0] : '+priority[0]);
if (priority[0]=="3")
{
var targetPrio='blocker';
print('\nSetting jira specific priority : '+targetPrio);
resultMap.put('priority', targetPrio);
}
}
}