Setting field based on Status and custom field

Hi,

Is the following possible? 

When an issue has a set state and a field has a 0 value then add date stamp anther field. 

Ie issue in state ‘Closure’ and ‘Open Orders’ Field goes to 0 date stamp add in ‘project Spend Completed’ field

Any help or ideas would be great.

Thanks

Kevin

1 answer

1 accepted

Hello Kevin.

Yes this is possible, but should it be done? That's the real question.

You can do this two ways:

1. Create a listener

You make a custom listener that registers onIssueUpdated events.

That listener checks the project and issue type relevant to you. If it is you check that the value of your custom field has changed. If it has you check that it's zero, if it's zero you set the timestamp of your other field.

2. Incorporate this behaviour in a scripted field.

You make a scripted field as follows.

  1. Define a variable that contains the value of it's current state. Let's call this A
  2. Define a variable that contains the value of the other field. Let's call this B
  3. If A is null, and B is 0, return a current timestamp.
  4. If A is null, but B isn't 0, return null.

But!

Both of this methods are quite heavy on your instance for something that you could do yourself. FE, you can create a REST endpoint that sets a timestamp to a field in an issue. Instead of setting a value to 0, you create a fragment that calls this rest endpoint when clicked.

Same thing, and less performance impacting on your instance.

If you need any help on this let me know.

Cheers!

DYelamos

Hi Daniel,

Thanks for the speedy answer.

The 'Open Orders' is imported information from our accounts system each night. 

Could option 3 still work?

Thanks

Kevin

You mean that it is ran automatically?

To be honest, if it's updated manually you need to go about this using listeners, if you want to keep it easy.

The more interesting route would be as follows:

Rest endpoint.

So your account systems at some point is calling the JIRA rest api via a script, I suppose.

If that is the case, you must have a list of the issues, or projects that you are updating. You can put that information in a JSON file.

With that JSON file, you can call another REST endpoint that does the calculation for the field, just after you do the import.

The rest endpoint would take that payload, and only do the calculations for the issues/projects necessary.

That is less performance affecting that anything else that I can think of.

Do you need information on how to go about this?

If so check our REST endpoints documentation:

And this answer of mine might help you craft a rest endpoint with authentifiation and JSON payload.

I hope this helped, if it did, please upvote my answer, and if it solved your problem, accept it so other users know this has been solved.

Cheers

Dyelamos

Hi Daniel,

This give me a lot of great information to go away and consider. 

 

Meny Thanks for all your help

Kevin

A pleasure, this would be interesting to do when I'm on support, if you want any help, create a new question and tag me in it. I'd be glad to give you a hand.

Cheers

Dyelamos

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

254 views 0 6
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