Setting field based on Status and custom field

Kevin Seery December 12, 2017

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

0 votes
Answer accepted
Daniel Yelamos [Adaptavist]
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.
December 12, 2017

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

Kevin Seery December 12, 2017

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

Daniel Yelamos [Adaptavist]
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.
December 12, 2017

You mean that it is ran automatically?

Daniel Yelamos [Adaptavist]
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.
December 12, 2017

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

Kevin Seery December 12, 2017

Hi Daniel,

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

 

Meny Thanks for all your help

Kevin

Daniel Yelamos [Adaptavist]
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.
December 12, 2017

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
TAGS
AUG Leaders

Atlassian Community Events