Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a Behavior to auto-populate the Summary of an issue based upon multiple field values

Brian LeTourneau
Contributor
June 9, 2021

When a user creates or edits an issue, I'd like the summary value of that issue to be auto-populated as the user enters values for 3 fields on the create/edit forms.

The summary value should look like "Pod - Name - Role"

Create issue screen.png

As you can see below, I've written 4 behaviors mapped to this project and issue type.  I don't feel like this is an elegant solution at all and it doesn't work.  I'm hoping someone far better at this than me can point me on the correct path.

My scriptrunner behavior summary code is:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY

@BaseScript FieldBehaviours fieldBehaviours


def summary = getFieldById("summary")
summary.setDescription("Will be set auotmatically when user selects Pod, enters a Name and chooses a Role")

 

My scriptrunner behavior pod code is:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY

@BaseScript FieldBehaviours fieldBehaviours

def pod = getFieldByName("Pod").value
def name = getFieldByName("Name").value
def role = getFieldByName("Role").value

def summary1 = getFieldById("summary")

//summary1.setDescription("Will be set auotmatically when user selects Pod, enters a Name and chooses a Role")
summary1.setFormValue("${pod.} + " - " + ${name} + " - " + ${role}")

 

My scriptrunner behavior name code is:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY

@BaseScript FieldBehaviours fieldBehaviours

def pod2 = getFieldByName("Pod").value
def name2 = getFieldByName("Name").value
def role2 = getFieldByName("Role").value

def summary2 = getFieldById("summary")

//summary2.setDescription("Will be set auotmatically when user selects Pod, enters a Name and chooses a Role")
summary2.setFormValue("${pod2} + " - " + ${name2} + " - " + ${role2}")

 

My scriptrunner behavior role code is:

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.SUMMARY

@BaseScript FieldBehaviours fieldBehaviours

def pod3 = getFieldByName("Pod").value
def name3 = getFieldByName("Name").value
def role3 = getFieldByName("Role").value

def summary3 = getFieldById("summary")

//summary3.setDescription("Will be set auotmatically when user selects Pod, enters a Name and chooses a Role")
summary3.setFormValue("${pod3} + " - " + ${name3} + " - " + ${role3}")

 

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events