Hi Team,
Recently I written a script to set field description as linked issues when selected issue from issue picker(Script runner issue picket field) but due to permission issue we are planning to change script runner picker field to JIRA insight field, but the same code not working for insight field.
Code:
The problem is that, since you are retrieving a value from an Insight field, you are getting an insight key, instead of an issue key.
So, you need to replace:
final issueKey = getFieldById("customfield_38711")
def issue = issueManager.getIssueByCurrentKey(issueKey.getValue() as String)
with something like:
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.riadalabs.jira.plugins.insight.channel.external.api.facade.ObjectFacade
@WithPlugin("com.riadalabs.jira.plugins.insight") def objectFacade = ComponentAccessor.getOSGiComponentInstanceOfType(ObjectFacade)
def insightObjectKey = getFieldById("customfield_38711").getValue() as String
// This should returns "OCM-3800 - Listing & Calendar Settings - Air Agile Calendar" def insightObjectLabel = objectFacade.loadObjectBean(insightObjectKey)?.label
def issueKey = (insightObjectLabel =~ /[A-Z]+-\d+/)[0]
def issue = issueManager.getIssueByCurrentKey(issueKey)
The snippet comes from this insight script documentation. Then, I improve it with our WithPlugin annotation to load autocomplete for classes when writing script. You can read more about ObjectFacade in its javadoc. Lastly, the "=~" is Groovy's find operator that match a substring using regex expression, which is documented here.
I hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
Olly here from Adaptavist Support!
May I ask, what version of ScriptRunner and Jira are you using?
Hope to hear from you soon!
Thanks,
Olly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Olly von Fay-Siebenburgen _ScriptRunner_ , Thanks for your reply,
I am using JIRA Data/Center 8.20.11 and ScriptRunner 6.58.1
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.