It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.ComponentManager import com.atlassian.jira.bc.project.component.ProjectComponent MutableIssue myIssue = (MutableIssue) issue; def customFieldManager = ComponentAccessor.getCustomFieldManager(); def deviceName = customFieldManager.getCustomFieldObjectByName("Device"); def componentValue = myIssue.getComponents()?.first()?.get("name") def changeHolder = new DefaultIssueChangeHolder(); deviceName.updateValue(null, myIssue, new ModifiedValue(issue.getCustomFieldValue(deviceName), componentValue), changeHolder);
Device is a text field.
Purpose is to copy the first item in the component/s field to the Device field.
It works correctly in JIRA 6.4.13 but fails when I have upgraded to JIRA 7.3.0
I assume that this code for postfunction. Since try this
import com.atlassian.jira.event.type.EventDispatchOption import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.UpdateIssueRequest import com.atlassian.jira.component.ComponentAccessor try { issue.setCustomFieldValue( ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Device") , issue.getComponentObjects().iterator().next().getName() ) ComponentAccessor.getIssueManager().updateIssue( ComponentAccessor.getJiraAuthenticationContext().getUser() , issue , UpdateIssueRequest.builder().eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).sendMail(false).build() ) }catch (NullPointerException e){ if(issue.getComponentObjects().iterator().hasNext()) throw e; }
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAs a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.