Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Populate Summary field, taking Dynamic 'Affect version' value created during Issue creation Edited

Hello All,

My Requirement is to Auto-Populate Summary field with concatenation of a Custom Field &  Affect version field, I have achieved it with Script runner Behavior. Also, have allowed only one affect version selection.

Now part of the Script works well when Existing Affect version is selected but If NEW AFFECT VERSION is created during Issue creation, it adds 'null' instead of version, so it seems not able to recognize New Affect/s Version value.

Behavior added -> Field 'Affect Version' selected -> Below code is written in server side script section



def OneAffectsVersion = getFieldById("versions")
Object AffectsVersion = getFieldById("versions").getValue();
String affectedVersion = null;
if (AffectsVersion instanceof ArrayList) {

//To Fetch Version value without []
if (AffectsVersion.size() > 0) {
affectedVersion = AffectsVersion.get(0) as String;

//To Allow only One affect version selection
if (AffectsVersion.size() > 1) {
OneAffectsVersion.setError("Build revisions may only have one affects version-New");
else OneAffectsVersion.clearError()

def CustomField= getFieldByName("CustomField").value
def summary = getFieldById("summary")
summary.setFormValue("${CustomField} ${affectedVersion}")


Kindly share what is going wrong or needs to be added to Fetch dynamic New Affect version created

Let me know if I can explain more.

2 answers

1 accepted

1 vote
Answer accepted

I have made some tests. The newly filled to-be-created version can't be retrieved with Behaviour.

Looking at your script, your use case can probably also be achieved with post-function.

1. Navigate Project Settings > Workflows > edit the appropriate workflow > click on Create transition > Post Functions > Add post function > Script Post-Function [ScriptRunner] > Custom script post-function.

2. Paste in the following script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue

def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName("CustomField").first()
def customFieldValue = issue.getCustomFieldValue(customField)
def affectedVersion = issue.getAffectedVersions().first()

issue.setSummary("${customFieldValue} ${affectedVersion}")
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, true)

3. Modify the order of this post-function after "Creates the issue originally.".

4. Publish the changes.

Thanks @Max Lim _Adaptavist_ It is working as required, however, it will not work on Issue Edit case so any way in which it can be implemented during Edit issue as well (Issue is edited, selected Affect version is removed and new version added so Summary to be changed) .Also, have to add Allow only one affect version selection.

Thanks again for your time!!

I didn't think you want to edit issue.

You can implement the same script as a listener on Issue Created and Issue Updated events:

1. Navigate ScriptRunner > Listeners > Create Listeners > Custom Listener.

2. Choose appropriate project, and choose Issue Created and Issue Updated events.

3. Under script: replace "issue" with "event.issue" in script above.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you