Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Add condition before issue raise in Jira

erfan pj February 2, 2019

Dears,

I used Jira API rest for raising the issue from another system, now I need to check a Customefield's value(which is come from another system) if it exists and status was Closed in My Jira, My issue on Jira should be Reopen and update some fields otherwise, I need to raise a new issue.

I'm really appreciated if someone tells me how could achieve this concern.

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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.
February 2, 2019

Hello,

You would need a plugin for it.

For example, you could use the Power Scripts plugin:

https://marketplace.atlassian.com/apps/43318/power-scripts-jira-script-automation?hosting=cloud&tab=overview

You could create a post function with a code like this:

if (#{custom field name} == "required value") {

    autotransition("Reopen", key);

}
erfan pj February 2, 2019

Thanks for your reply.

So, how can I prevent to raise a new issue if customefield existed and just update the existence issue and reopen it.

Alexey Matveev
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.
February 2, 2019

You could write a validator:

string [] keys = selectIssues("customfield = yourvalue");

for (k in keys) {

   if (%k%.status == "Closed") {

      autotransition("Reopen", k);

      return false, "Issue " + k + " was reopened";

   }

}
erfan pj February 2, 2019

Thank you so much Alexy,

 

I used this code but seems its never being fired when I create the issue.

Would you please check below concerns, maybe there is some misunderstanding.

 

  1.  I have another system and I used below API from Jira to raise an issue when sth happened in the second system.   /rest/api/2/issue and I used script runner in Jira to close activity in the second system when Jira status is closed.
  2. Now I need to set a condition before raising an issue in Jira to check if activity id in the second system existed in my Jira, related Jira issue should be reopened with new details otherwise raise a Jira issue

so, would you please assist how can we achieve this? 

erfan pj February 2, 2019

And also please be informed, I don't have access to second system and they just call my jira API for creating an issue and i have to validate the concerns in our(Jira) side

erfan pj February 2, 2019

Thanks, it is work now.

 

just one more thing, how can I get the value of customfield_108987 when the second system calls my API for raising the issue.

Suggest an answer

Log in or Sign up to answer