Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Summary

Within JEMHC all field updates use a centralized template (Issue Updated) and can be merged into the same event. The below example shows to include custom messages based on which field has been changed along side showing all of the included field changes.

Example

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

#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>
                    &gt;
                    <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 == "status")
		                    <tr>
		                        <td>
		                            <table>
		                                <tr>
		                                    <td>
		                                        <table>
		                                        #foreach( $item in $changeLogMap.get($fieldId))
		                                            <p> This issue has been transitioned to $!jemhUtils.htmlEscape($!jemhUtils.renderValue($context.issue, $fieldId, $jemhUtils.getChangeLogToValue($item)))
		                                            #end
		                                        </table>
		                                    </td>
		                                </tr>
		                            </table>
		                        </td>
		                    </tr>
				#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>&gt;<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
  • No labels