I’m stuck trying to figure out how to update custom fields in JIRA through code. The docs are confusing and I’ve tried a few things without success.
I thought this would work:
myField.updateValue(customField, newValue);
But it only seems to change the value temporarily. It doesn’t actually save to the database. This might be okay for some workflow stuff but it’s not what I need.
I’m running JIRA 4.3.2 and I really need to find a way to permanently save these custom field changes. Any ideas on how to make it stick in the database? I’ve been banging my head against this for days now!
As someone who’s been in the trenches with JIRA customization, I can relate to your frustration. The API can be a real pain sometimes. Here’s what worked for me:
Instead of using myField.updateValue(), try this approach:
This method actually commits the change to the database. Make sure you have the necessary permissions set up correctly, or you’ll just end up pulling your hair out.
One gotcha to watch out for: if you’re dealing with multi-select custom fields, you might need to use a Collection instead of a single value. Also, don’t forget to refresh your issue object after making changes if you plan to keep working with it.
Hope this helps you get unstuck. JIRA development can be a beast, but once you get the hang of it, it’s pretty powerful.
Having worked extensively with JIRA’s API, I can tell you that updating custom fields programmatically can be tricky. The method you’re using only updates the value in memory, not in the database. For a permanent update, you need to use the issue.update() method.
This approach ensures the change is persisted to the database. Make sure you have the necessary permissions and that you’re handling any potential exceptions. Also, remember to refresh the issue object after the update if you need to work with it further.