Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,526
Community Members
 
Community Events
184
Community Groups

Post function : Single select list custom field values setting on WF Transition

This is the below code i have used and had no working , Aggregate status is the field name , Design is the values want to set on transition Todo ==> inprogress 

Code 1 tried : 

def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'MyCustomFieldType'}

issue.setCustomFieldValue(cf, 'Design')

compiled without error and its not working

Code 2 tried : 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.customfields.manager.OptionsManager;
import com.atlassian.jira.issue.customfields.option.Option;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.MutableIssue;
MutableIssue currentissue = currentissue // Any one please explain what is mutable issue ? 
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Aggregate status'}
def fieldConfig = cf.getRelevantConfig(issue)
Option value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.value == 'Design' }
issue.setCustomFieldValue(cf, value)  

 

its not working and I need assistance from community  . 

 

Thanks and i appreciate your information . 

 

 

 

2 answers

1 accepted

2 votes
Answer accepted
Aditya Sastry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 02, 2020

@Maha vishnu v  Try this. I have tested it and it works. Accept the answer if you are happy so it can help others too.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

// the name of the custom field (single select list type)
final String customFieldName = "AIQ Detectability"

// the value of the new option to set
final String newValue = "Yes"

def customField = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
//assert customField : "Could not find custom field with name $customFieldName"
def availableOptions = ComponentAccessor.optionsManager.getOptions(customField.getRelevantConfig(issue))
def optionToSet = availableOptions.find { it.value == newValue }

customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), optionToSet), new DefaultIssueChangeHolder())

@Aditya Sastry  , 

Its working and i'm happy with your answers . 

Can you please help me on this additional same functionality below with code alternatives  for Date field and multiple select list fields ? 

On transition i would like to defining Due date and Multiple select list field values  in place of ( select list field in above code  ) 

your answers could be more helpful . 

 

And Please correct my code in description , Where it was wrong and i would like to get  good approaches to learn script runner with groovy scripts ? Since I'm a beginner , this could be more helpful to get started .

Much Thanks !

@Aditya_Sastry, 

Do you have any information on my above appended request  ? 

If yes , It helps me a lot ! 

Hi can we do use the same JIRA 8.2? 
I am unable to do.

When user transit in Progress it should set customfield_xx (single select) value to 'ABC'.
Before In progress there is no value for the above custom field.

Any help will be appreciated.
Thanks!

0 votes
Aditya Sastry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 02, 2020

What plugins do you have? Let me know so I can help you with the changes.

Aditya Sastry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 02, 2020

try this -

issue.setFieldValue("Aggregate status",'Design')

Aditya Sastry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 02, 2020

did you try the above suggestion?

Script Runner is the only plug-in in use 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events