Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Roberto Saltini
Contributor
September 21, 2016

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 votes
adammarkham
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.
September 22, 2016

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.

0 votes
Roberto Saltini
Contributor
September 22, 2016

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 votes
Roberto Saltini
Contributor
September 22, 2016

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.

0 votes
adammarkham
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.
September 22, 2016

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.

0 votes
Roberto Saltini
Contributor
September 22, 2016

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

0 votes
adammarkham
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.
September 22, 2016

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. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events