You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello,
I have a custom field that is used to pick from a list of change tickets. Can I somehow automate via script so that when a user selects a value in custom filed, that value (an url to another ticket in another tool) is added to Issue Links as a "links to" Web link?
I am a total newbie to Jira and had no luck using GUI to automate this, Would really appreciate some help with script automation. Thank you!
Hello @Mihailo ,
If you are using ScriptRunner you could use a script listener on the issue updated event (and any other event that might be triggered when you select a value). This is assuming that the field is a select list :
import com.atlassian.jira.issue.link.RemoteIssueLinkBuilder
import com.atlassian.jira.issue.link.RemoteIssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.link.RemoteIssueLinkManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def fieldChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Select List Field"}
if (fieldChanged) {
def selectListId = 12200
def customField = customFieldManager.getCustomFieldObject(selectListId)
def customFieldValue = issue.getCustomFieldValue(customField).getValue()
RemoteIssueLink link = new RemoteIssueLinkBuilder().issueId(issue.getId()).url(customFieldValue).title(customFieldValue).build();
ComponentAccessor.getComponent(RemoteIssueLinkManager.class).createRemoteIssueLink(link, ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser());
}
replace "Select List Field" with the name of your field and 12200 with id id of your field.
Hope that helps.
Thank you so much @Antoine Berry ! I created a working Listener using your code.
Is it possible to modify it to accept multiple selections? Something like a for Each?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mihailo ,
You mean you are using a multiple values select list, and would like to create a link for each value ?
Yes, that would be possible by iterating on the custom field value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, that is exactly what I need. Do you have some links on iterating in ScriptRunner?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.