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

Peter Pesta March 16, 2017

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

0 votes
Alexandru Geageac
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2017

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

NC Atlassian March 17, 2017

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