Hi all,
I'm using the script runner plugin to write some post functions for my JIRA instance and i've run into a bit of a problem. I am setting some values returned from a web service into some fields on my issue at the point it is created. The value i am setting should then appear in the header of an email. Previously i've done this with the value being entered into the same field in JIRA directly and that works correctly so i know the velocity template update i have implemented is correct. The issue i am having is that the velocity templates appear to not be able to see the updated field, so i am getting an email value which comes out something like this:
myProject / $issue.getCustomFieldValue("customfield_10301") / XYZ-123456
instead of:
myProject / myWebServiceValue / XYZ-123456
I am setting the value in the first post function that is actioned after the initial create post function. I am using the following function to set the value within the groovy script:
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), nodes.item(0).getNodeValue()),changeHolder)
(it's being pulled out of the service response using xpath, hence the nodes item). I've used this function before and it usually persists changes across various post function scripts so i'm not sure why it should be any different for the email generation if the update is made to the issue before the event fires in the post functions. Any help with this would be much appreciated. Thanks.
If you are in the first post-function you should use simply:
issue.setCustomField( cf, "whatever" )
you don't need the changeholder stuff. You need that if the issue has already been stored and indexed by the time your post-function runs.
That you see the velocity stuff in the email suggests that the value was null... check for errors in your log, maybe mail log.
This was the problem, i swapped my previous set code for this code on this field so now I use: issue.setCustomFieldValue(tgtField, nodes.item(0).getNodeValue()) and the email title generates correctly. I don't fully understand how this differs from the other function with regards to the data the email then uses to generate as previously the value was definitely populated on the issue and there were no errors in the logging when populating it/during email generation so I'm not sure I understand why this fixed it but it has. Thanks for your help Jamie, much appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.