Edit Fields Variable Expansion in JIRA Automation Plugin

JIRA Automation Plugin, the Edit Fields screen mentions

 

If you allow variable expansion, you are able to manipulate fields in a more dynamic way.
  • You can use the default fields, like: $issue.summary, $issue.description and $issue.assignee.name
  • You can use custom fields, by providing their ID, for example: $customfields.get(10000)
  • To assign a value to a customfield, you can use: customfield_10000=Example: $issue.summary
  • To prepend a value from a customfield before the summary, you could do use: summary=$customfields.get(10000) $issue.summary
  • Text and number fields are currently the only supported custom fields

Where can I get a full list of these variables? This looks to be very handy.

2 answers

1 accepted

We are inserting the whole issue object into the Velocity renderer. Most of built-in fields should work (such as priority etc). You may be able to use similar variables as in email templates. Even branching is possible, same as in other Velocity files.

@Matej Konecny

Thank you for the response.  

Objects that are referable by JIRA Automation Plugin

I'm not a programmer, but I think I the two "objects" that JIRA Automation Plugin sets are issue and custom fields (basically, those are additional fields for issues, in addition to the built-in fields).

EditIssueAction.java Excerpt:

        context.put("issue", issue);
        context.put("customfields", new CustomFieldValueRetriever(customFieldManager, issue));

 

Issue Fields

Are these the places to find the built-in fields?

Branching

What is branching? Is that like $issue.reporter? In fact, what I am trying to do is get to a reporter's group, or a reporter's custom properties. I will post that question separately. Thanks again.

 

 

Fields

The issue object is passed as a GenericValue (GV) and Velocity uses public Getters to derive appropriate method similar to the logic here:

issue.getSummary() -> $issue.summary
issue.getPriority().getName() -> $issue.priority.name (I think, never tested)

Basically, object of type https://docs.atlassian.com/jira/latest/com/atlassian/jira/issue/MutableIssue.html is passed, so in theory all methods starting with get* should work.

Branching

You can use standard Velocity formatting template, look at this:

customfield_14080=#if($customfields.get(14080) == 'Urgency 5')13080#elseif($customfields.get(14080) == 'Urgency 4')13081#elseif($customfields.get(14080) == 'Urgency 3')13082#elseif($customfields.get(14080) == 'Urgency 2')13083#end

Make sure it's on one line though smile

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

746 views 5 17
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot