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 Tuesday in Statuspage

How do your teams prepare for really high (planned) traffic days like Cyber Monday?

Hi there! Shannon from Statuspage here.  👋  With Cyber Monday quickly approaching, we're looking to hear from Atlassian customers – specifically from teams who touch incident response li...

57 views 0 5
Join discussion

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