The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Maxim Zaripov
January 19, 2021

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 Champions.
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