Custom Field Value Not Displaying in View Issue Screen after setting the value Programmatically?

From the Issue Tab Panel Java Class, I am setting the value to Multi line Text custom field, after refreshing the page 2 times, the value appears on the screen.

I am using the Below code for adding the custom field value.

 

CustomField customFieldName = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Confluence Pages");        
MutableIssue mutIssue = ComponentAccessor.getIssueManager().getIssueObject(issue.getId());
ModifiedValue mVal = new ModifiedValue(mutIssue.getCustomFieldValue(customFieldName), "URL Values" );            
customFieldName.updateValue(null, mutIssue, mVal, new DefaultIssueChangeHolder());              
IssueIndexingService issueIndexService = ComponentAccessor.getComponent(IssueIndexingService.class);             
boolean origVal = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
issueIndexService.reIndex(issue);
ImportUtils.setIndexIssues(origVal); 

 

Refreshing the Page 1st time gives me value inside the edit mode of custom field. screen shot below.

Capture1.PNG

In the below image only 1 value is shown, but when i refresh for 2nd time, it shows the value.

Capture2.PNG

After 2nd time refresh. i get the value.

Capture 3.PNG

 

 

2 answers

Hey arunk I'm having issues getting customfield values as well. One problem I noticed in your code is that you are using getCustomFieldObjectByName. Depending on the version of Jira you are using this is deprecated so it needs to be changed. The new field is getCustomFieldObjectsByName and will return a collection of all custom fields with that name. 

Since the Issue Detail is rendered first and then the Issue Tab Panel is rendered, at first refresh the value of custom field is set, but the Issue Detail being already rendered it was not able to show the custom field value, this is the reason why the Custom field value is displayed at the second refresh of the page. 

I resolved it by removing the field from the Issue Detail, since i need this only at the Issue Navigator.

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 May 30, 2018 in Marketplace Apps

Three tips for boosting your board's efficiency with Story Maps

Trello is one of the most effective tools for driving your sprints. It's customizable for every Agile team and product owners and Scrum masters (SM) love it. However, Agile teams often struggle with:...

818 views 2 9
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