How to pass values between two post-function scripts that belong to the same transition?

I am working on being able to create an issue and automatic link this issues to multiple issues with different link types on the post-function of the Create transition.

As a note, I cannot use the stander Linked Issues field because I need to be able to create different type of links.

My workaround is adding custom fields to the Create Screen where I specify the issues a want to link to and the linktype so that I can then access these fields in the Create post-functions.

However, I would like these custom fields not to be stored in the database because they are meaningless after the creation process has been completed.

So, my idea is to have a post-function to be execute before  the standard post-function "Creates the issue originally." This post function would store the values of the custom fields "somewhere" and then set these custom fields to null so that they will not be stored into the database.

Then another post-function would be executed after the standard post-function "Creates the issue originally". This post-function would fetch the custom fields values stored "somewhere" and use them to link the newly created issue to the other issues.

So, how can I pass values between these two post-functions?

 

 

6 answers

0 vote

You should probably only have one scripted post function that reads the custom field values, does the update then finally clears the values for these custom fields. Passing data between post-functions may be a pain.

What did you envision the create issue screen to look like with these fields? Perhaps if you could provide a screenshot I can add some code to get you started. 

Are you suggesting to add this post function after the standard post-function "Creates the issue originally" ?

0 vote

Yes, it will need to be created before you can access it in the post-function. Happy to add some code to make it clearer once I know what data you'll be passing in the fields.

I was hoping to being able to avoid having the issue created and then having to update it to clear the values. My idea was to pass the values from a post-function execute before the standard post-function "Creates the issue originally" to a post-function executed after the standard post-function "Creates the issue originally" so that when the issue is create the custom values have already been cleared.

issue is not null before creating the issue. Before creating the issue "issue" reflects the value inputted in the Create Screen. I did add the following code before creating the issue

issue.summary = 'Hello'

and all of the issue created afterwards had the field summary set to 'hello'

 

0 vote

Your right, i'm sure it worked like that some time ago. It definitely needs to be stored first before you retrieve it again maybe that was it. You'll probably have to use the setters in the issue object to set the fields before its stored in the database.

I still don't think you would need two post-functions.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

71 views 0 11
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