JIRA SERVER

Introduction

In some cases, your counterparty would like to see who changed the content of a custom field.  The following snippets shows

  • how to access the JIRA authentication context which contains that specific information. 
  • Store it in a Custom Keys
  • Extract it from the custom key on the other side, and add the information as a comment

Source side

Data filter

// Get the message to be sent to the customer from a custom field
replica.customKeys.messageForCustomer = issue.customFields."External Message".value

// get the current logged-in user and store it in a customKey 
replica.customKeys.currentUser = com.atlassian.jira.component.ComponentAccessor
										.getJiraAuthenticationContext()
										.getUser()?
										.displayName

both messageForCustomer and currentUser can be null because dataFilter is also called (in certain cases) asynchronously to provide responses

 

Destination side

Create/Change processor

Use the customKey: if the messageForCutomer is provided, add a comment prefixed with the full name of the currentUser.  Use 'development' if no user provided.

if (replica.customKeys.messageForCustomer != null) {
   String author = replica.customKeys.currentUser ?: "development"
   String messageBody = author + " : \n" + replica.customKeys.messageForCustomer
   issue.comments = commentHelper.addComment(messageBody, issue.comments)
}
 

Back to advanced configuration