Forums

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

Read custom field value set by previously run post-function in post-function

Martin Fink
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 21, 2018

Hi,

 

In our company jira we have two custom post functions, which run after each other. The first one calls an external api and sets a custom field based on the returned value.

The second post function needs to retrieve the value in the custom field.

 

My problem is that when the functions are triggered, the first function writes the value, but in the second function i get null when I read that custom field.

The value is shown in the issue overview after the functions are run. 

 

Relevant code:

Function 1, setting the value

customField.updateValue(
null,
issue,
new ModifiedValue<>("", String.valueOf(response.getData().getTaskId())),
new DefaultIssueChangeHolder()
);

Function 2, retrieving the value

CustomField customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(customFieldId);
Object value = task
.getCustomFieldValue(customField); // null

 

Thanks in advance.

1 answer

1 accepted

0 votes
Answer accepted
Nir Haimov
Community Champion
September 21, 2018

Hello and Welcome to Atlassian Community!

1. I recommend you to merge the 2 post-function into 1, especially if the second depend on the first.

2. Does your first script work? does the field get updated with a value eventually?

Martin Fink
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 21, 2018

Hi,

 

1. I thought about that, maybe it's the best solution.

2. Yes, the value gets set, I can see it in the issue overview after all post functions have run. It's just that the second function cannot read the value.

Nir Haimov
Community Champion
September 21, 2018

So try to combine them into one and see whats happen.

Let me know if it work or you still have an issue :)

Suggest an answer

Log in or Sign up to answer