Hi - I have a Scriptrunner Scripted field that works fine, and correctly returns one of two values : 'Planned' or 'Un-Planned'. I have used a "Exact Text Searcher (natural)" as the search selector for the script field, which allows me to use the result of the scripted field in all the dashboard widgets and reports....except a 3rd party barchart plugin called 'Barcharts for JIRA'. For some reason it cannot pickup on the value of my scripted field (or epic links either, if that's relevant).
My idea was to create a second, normal text field (which the bar chart plugin can handle), and copy the value of the scripted field into the text field. I have tried using the Behaviour module in script runner, but it is returning the value of the scripted field as 'null'
I have been using basically this syntax:
def targetVal = getFieldByName("customfield_10836") def sourceVal = getFieldByName("Planned/Unplanned") targetVal.setFormValue(sourceVal)
I also tired adding .value, .text, .toString() etc.to the end of the targetVal line, but I just cant seem to capture the actual textual value of my script field.
What am I doing wrong? Could anyone give me example code some example code to put in the initialize function of the behaviour
Hi, so I got the best solution possible in the end; the guys at TNG tech who make the plugin released a new version (3.3) that natively/automatically supports scripted fields!
No need for behaviours, listeners etc. Although I enjoyed trying to workaround my original problem, even if it was long winded!
Scripted fields cannot be added in a screen therefore
"Scripted Field A") will return null every time. Instead you can retrieve it's value via the CustomFieldManager. So in a behaviour, in order to get the value of a scripted field:
import com.atlassian.jira.component.ComponentAccessor def scriptedField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Scripted Field") def scriptedFieldValue = underlyingIssue?.getCustomFieldValue(scriptedField)
Thank you, that got me a bit closer to achieving what I want. I now am able to read the script field's value and copy it into my 'slave' text field...but...something is happening I don't understand.
My Script field and my 'slave' text field are on my 'view issue' screen. Neither of them are on my 'create issue' screen (intentionally). If I create a new issue, and then navigate to it, the script field works as it always has done and displays a value, but my slave field is initially blank. If I hit the 'edit' button, change nothing and simply hit the update button, the edit screen disappears and now back on the view issue screen the behavior you helped me with fires, and successfully copys the value of the script field to the slave field.
Why does the behaviour only fire by going to edit mode? And is there a way to change this so it happens automatically when an issue is initially created?
I intend to eventually hide this slave field eventually once I get it to work, if this affects the answer...
Any help or advice appreciated
As a side note, you might file a bug with the makers of Bar Charts.
Hi - so I actually managed to achieve what I needed. I used a custom event listener that fires when a new issue is created in my project. I check the script field and slave field exist in the issue that fired it, then check the issue type, and if it is the relevant one I grab the value of the script field and write it into the slave field. The original behaviour then works and keeps the field in sync if the issue is ever edited. Clunky, but works .
Still open to suggestions for a more elegant solution if anyone has the time...
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
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:...
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!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG