How to use "Set field Value to constant or Groovy expression"?

I want to change the value of the fields "Zusammenfassung" (summary) and "Projektnummer" (projectnumber) in a transition.

If you click the button "next" the field "projectnumber" should be automatically filled with the issue-number without the projectkey "RQ-" infront.  

My idea was it to put a groovy script in here:

Set Field Value to constant or Groovy expression Function2.jpg

issue has the number: "RQ-123"

resulting projectnumber: "123"

 

after this, i want to get the issue number in front of the summary, for example:

issue has the number: "RQ-123"

summary("Zusammenfassung" in german): "Testentry"

resulting summary("Zusammenfassung"): "123: Testentry"

Set Field Value to constant or Groovy expression Function.jpg

i tried to return strings, but nothing happend...

 

 

1 answer

1 accepted

This widget could not be displayed.

For Projektnummer, if that field is a Text custom field:

issue.get("issuekey").split("-")[1];

If it's a Number custom field:

Integer.parseInt(issue.get("issuekey").split("-")[1]);

For Zusammenfassung (summary):

issue.get("Projektnummer") + ": " + issue.get("summary")

Of course, post-functions must be put in the right order (Projektnummer first).

If something doesn't work, first thing to check is atlassian-jira.log (JIRA's logfile).

Thank you for the fast answer!

After some changes this works fine to me:

  • Projectnumber:
Double.parseDouble(issue.get("issuekey").split("-")[1]);

I used double instead of integer...i otherwise got an error.

  • Summary:
String.valueOf(issue.get("Projectnumber")).split("\\.")[0] + ": " + issue.get("summary");

 

 

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published Jul 25, 2018 in Marketplace Apps

Jira Cloud and Bitbucket Cloud Integration with Microsoft Teams

One of the newest products in the Microsoft family - Microsoft Teams,  is a chat-based hub for teamwork that integrates all the people, content, and tools your team needs to be more engaged and ...

717 views 0 3
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