Forums

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

Script runner manual.

397379ghz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 13, 2019

Greetings. Where I can find information or vocabulary which help me writing scripts in Script Runner? I found a lot of examples but I don't found information about meaning of those scripts.

Example:

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level

log.setLevel(Level.DEBUG)

//Grab necessary Components
def cfm = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()

def clientName = "Acme"
def sourceName = "My Source"

log.info("clientName: " + clientName)
log.info("sourceName: " + sourceName)

//Set custom text field
def cfClient = cfm.getCustomFieldObjectByName("Client")
issue.setCustomFieldValue(cfClient,clientName)

//Set custom single select field
def customField = cfm.getCustomFieldObjectByName("Source")

log.info(customField.getName() + " customField before: " + issue.getCustomFieldValue(customField))

def fieldConfig = customField.getRelevantConfig(issue)
def options = optionsManager.getOptions(fieldConfig)
def option = options.find{it.value == "My Source"}

issue.setCustomFieldValue(customField, option)

log.info(customField.getName() + " customField after: " + issue.getCustomFieldValue(customField))

 

________________________________________

import com.atlassian.jira.component.ComponentAccessor -  why we importing Comp accessor - and what is it, I have no idea

def customField = cfm.getCustomFieldObjectByName("Source") - def customField...ok, I understood it, but... cfm.getCustomFieldObjectByName("Source")... no idea, where I can find some information about those commands? Mb it's part of Groovy language, I really lost, pls help. Thank you.

 

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Marc Minten (EVS)
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.
May 14, 2019

I think you best start with a groovy tutorial (there are several on the net), then go through the scriptrunner documentation, try to copy and adapt some examples, and finally search specific examples on the net.

(part of) the Jira API can be found at https://docs.atlassian.com/software/jira/docs/api/, but this is no cook-book, but a reference guide....

397379ghz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 14, 2019

Thx so much. I'll try!

TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events