Forums

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

jira.ComponentManager jira 8

Maxim Zaripov January 19, 2021

Hello

Help me please

I need a code that, when done transitions, will change the custom date/time field to a constant.

2 answers

0 votes
Maxim Zaripov January 19, 2021 edited

I started learning script runner. I found an article on the Internet about changing custom field.  

Import com.atlassian.crowd.embedded.api.User 
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

ComponentManager componentManager = ComponentManager.getInstance()
IssueManager issueManager = ComponentAccessor.getIssueManager() CustomFieldManager customFieldManager =componentManager.getCustomFieldManager()

User curUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() MutableIssue curIssue = issueManager.getIssueObject("PRJ-1")



CustomField cfReleaseVersion = customFieldManager.getCustomFieldObjectByName("Release Version") curIssue.setCustomFieldValue(cfReleaseVersion, "3.5")
issueManager.updateIssue(curUser, curIssue, EventDispatchOption.ISSUE_UPDATED, false)

My jira 8. Jira 8 don't have import com.atlassian.jira.ComponentManager.

What do I do? I'll want to do it after transition "closed"

0 votes
Pedro Felgueiras
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.
January 19, 2021

Hi @Maxim Zaripov

 

Please detail what you have done so far and where you are having difficulties. 

Maxim Zaripov January 20, 2021

yes

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events