Unable to Get Portfolio`s Team Custom Value in Seperate Thread

We are trying to get Portfolio’s Team custom field value on separate thread by using JiraThreadLocalUtil with method issue.getCustomFieldValue(field). Unfortunately, the result is null. But the same code, we can get other custom fields` value successfully, like custom field in type of Custom Label. And also, same code returns the value of Team custom field when it is run on main thread.

Can you please help us that why the code does not return Portfolio`s Team custom field value while run on separate thread?

1 Like

May I ask what user account is authenticated in the separate thread?

Actually, I am not well experienced. But I try this code: ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
And see, in main thread it returns a value, my admin user. But in separate thread it returns null. Just like getting Team custom field value.
In other words, we can say that in thread, there is no authenticated user. But, in the same path, I can get issue from ComponentAccessor.getIssueManager().getIssueObject.

Can you pass the user as a parameter into your new thread and use the JiraAuthenticationContext#setLoggedInUser(ApplicationUser) method to set the user context on that thread?

Portfolio has Permissions and you have to be in the group defined under Portfolio Permissions in order to retrieve values, so your anonymous thread is probably failing there.

1 Like

Thank you Stewen, that was the problem. I used JiraAuthenticationContext#setLoggedInUser to add my application user. And finally got the Team custom field value.

1 Like

There are some inconsistencies in the style of API Jira is using.

  • The IssueManager class does not check permissions and and does not care about an authenticated user on the thread.
  • The IssueService class checks permissions via a passed in parameter but should not care about an authenticated user on the thread.
  • Portfolio fields check permissions via the authenticated user on the thread.
1 Like