It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update custom field in another issue using post function (ScriptRunner or JJupin)

Dear all,

I need to create a post function that will edit a custom field in another issue in another project. The post function should increase the number with a plus 1. (e.g. custom field value is 10, so the post function will update it to 11).

Background:
Multiple Issue types within a project and each issue type will have his own ticket nr field. This ticket nr field should be a string with a number on the end which represent the number of the issue types (just like the number in key in jira), but with the difference, that now the key number is increased by one no matter what type of issue type is created. I need to use a different prefix for the ticket nr. field for each issue type.

Example:
Ticket nr field should contain <prefix><YY>-<nr>
Issue type A has prefix for the ticket nr field AAA
Issue type B has prefix for the ticket nr field BBB
Issue type C has prefix for the ticket nr field CCC

When creating the first issue type A, the nr at the end of the ticket nr field will be set to 1, afterwards, when I will create the first issue type B, the nr at the end of the ticket nr field will be also 1. (since it is the first issue type B).

The calculation of the amount of the issues is maintained in a hidden project with just one issue type with counter fields for each issue type (A, B, C, ...) and now I need a scripted post function that will update the counter field with an automation increase each time I create a issue type A, B, C etc. in a different project. 

JIRA Core 7.2.2
JJupin 3.1.8
Scriptrunner 4.3.13

Unfortunatelly I have no scripting experience or knowledge.
Thank you in advance for your help.

Kind Regards,

Peter

1 answer

Hi Peter,

So you want a field to return how many issues from that issue type exists in a project or to return an index for the number of the issue for that issue type?
Take a look to the countIssues routine (https://confluence.cprime.io/display/SIL/countIssues).

Best Regards,
Alex

Hi Alex, 

Thank you very much, I want to count how many issues from that issue type was created. The thing is, if some user would delete an issue, it could end with two issues having the same ticket nr, therefore I need to retrun how many issues from that issue were already created till now and add an +1 and update the field.

Kind Regards,

Peter 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

1,099 views 7 0
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you