Forums

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

Access smart value in Scriptrunner script

Dan Knapton April 29, 2025

Have a script that will add a new Component to a project from an Automation. It works well when I hard-code the parameter values.  Btu I can't get it to plug in smart values from the Automation.  

This doesn't work:

def summ = Issues.getByKey('{{issue.key}}').summary
def summ = Issues.getByKey('{{issue}}').summary
def summ - {{issue.summary}}
What is the correct syntax to bring in a smart value?
Jira Data Center 9.12
Scriptrunner 8.36

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
3 votes
Answer accepted
Charlie Misonne
Community Champion
April 30, 2025

Hi @Dan Knapton 

So you are executing a scriptrunner script withing an automation rule?

Smart values are very specific to automation rules. They do not exist in groovy/ scriptrunner scripts even when using the scriptrunner action.

Here is some documentation: Execute a ScriptRunner Script 

you can simply use:

def summ = issue.summary

Assuming your rule is being triggered by an issue event and you need that issues's summary.

Dan Knapton April 30, 2025

Thank you that worked perfectly.  

I had reviewed that <slim> documentation about smart values on that page and it seemed to indicate I needed the mustaches.  All examples I could find had hard-coded values in single quotes.

Would you know how to reference project smart values in a script in Automation? ie. project id or key

Charlie Misonne
Community Champion
April 30, 2025

You're welcome! Glad I could help.

 

 

 

Would you know how to reference project smart values in a script in Automation? ie. project id or key

 

Is this also for a rule being triggered by an issue? In that case issue.getProjectObject().key or issue.getProjectObject().id should work.

 

 

0 votes
Matthias Sohn May 12, 2025

from scriptrunner documentation :

You can evaluate smart values using ruleContext.renderSmartValues(String)for example:

log.warn ("Initiator of the action was... " + ruleContext.renderSmartValues('{{initiator}}'))

TAGS
AUG Leaders

Atlassian Community Events