...
Within this example it uses the Jira Theme and renders a custom message when the Status Field has been changed. To use with the default templates, you can enter this custom macro within JEMHC > Notifications > Custom Macros
Within the below example, it contains a If statement which checks if the fieldId is “status” and if so then it will render the custom message, if it is not “status” then it would perform the default rendering for the field changes. The custom if statement starts at line 45.
Code Block | ||
---|---|---|
| ||
#macro ( jemhIncludeChangeLog) #if($context.transition) <tr> <th> $context.transition.transitionName.textValue(): </th> <td> <ul style="display: inline; margin: 0; padding: 0;"> <li style=" display: inline;"> $jemhUtils.setFieldRendered() <span style="background-color:#ffe7e7;text-decoration:line-through">$context.transition.from_status.textValue()</span> > <span style="background-color:#ddfade">$context.transition.to_status.textValue()</span> </li> </ul> </td> </tr> #end #if (!$serviceJiraUpdateFields) #set ($serviceJiraUpdateFields = []) #end #set($changelogContext = $jemhUtils.getChangeLogsByShowFields($context, $serviceJiraUpdateFields)) #if($changelogContext && $changelogContext.size() > 0) #set($entrySet = $changelogContext.entrySet()) #if($entrySet && $entrySet.size() > 0) <tr> <th> <h3>$messageUtils.getMessage('updates')</h3> </th> </tr> #foreach ($aMapEntry in $entrySet) #set ($timestamp = $aMapEntry.key) #foreach($aEntry in $aMapEntry.value.entrySet()) #set ($author = $aEntry.key) <tr> <th> #userJemhIncludeStandardActionHeader($author.accountId, $timestamp) </th> </tr> #foreach($aChangelogMap in $aEntry.value) #set ($changeLogMap = $jemhUtils.indexChangeLogByField($aChangelogMap)) #if($changeLogMap) #foreach( $fieldId in $changeLogMap.keySet() ) #if($fieldId == ## Start of custom If Statement ## #if($fieldId == "status") <tr> <td> <table> <tr> <td> <table> #foreach( $item in $changeLogMap.get($fieldId)) #foreach( $item in $changeLogMap.get($fieldId)) ## Start of custom Content ## <p> This issue has been transitioned to $!jemhUtils.htmlEscape($!jemhUtils.renderValue($context.issue, $fieldId, $jemhUtils.getChangeLogToValue($item))) ## End of custom Content ## #end </table> </td> </tr> </table> </td> </tr> #else ## Else to perform default field update rendering (so field changes are not </tr>missed) #else <tr> <td> <table> <tr> <td>#getFieldName($fieldId):</td> <td> <table> #foreach( $item in $changeLogMap.get($fieldId)) $jemhUtils.setFieldRendered() #if($fieldId == 'WorklogId') #set( $worklog = $jemhUtils.getWorklogById($context.issue, $jemhUtils.getChangeLogToValue($item))) #if(!$jemhUtils.isNull($worklog) ) <tr style=" display: inline;"> #if($foreach.count>1) <hr> #end <a href="$jemhUtils.getUserProfileUrl($worklog.author)">$jemhUtils.htmlEscape($jemhUtils.getUserDescription( $worklog.author))</a> : $!worklog.timeSpent.asText() <p>$jemhUtils.wikiToHtml($worklog.comment.asText())</p> </tr> #end #else <tr style=" display: inline;"> <div> <span style="background-color:#ffe7e7;text-decoration:line-through"> $!jemhUtils.htmlEscape($!jemhUtils.renderValue($context.issue, $fieldId, $jemhUtils.getChangeLogFromValue($item)))</span>><span style="background-color:#ddfade">$!jemhUtils.htmlEscape($!jemhUtils.renderValue($context.issue, $fieldId, $jemhUtils.getChangeLogToValue($item)))</span> </div> </tr> #end #end </table> </td> </tr> </table> </td> </tr> #end #end #end #end #end #end #end #end #end |