Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change a Jira Custom Field's stored value dynamically?

Orkun Gedik June 7, 2018

Hi everyone, I am developing a custom field plugin for Jira. I want to use my custom fields with ScriptRunner's behaviour feature. The problem I met as follows;

For instance I have a custom field named "myField" which is a single select type custom field and it appears on the issue creation screen. I build a server side script to follow my logs. When I open a issue create screen and change "myField" option, the stored value of my field returns empty. Furthermore, It does not even return null when there is noting selected yet. However, when I click create button without filling required fields and then getting errors for those fields which have to be filled, my fields value changes correctly and appears in my log. 

In short, what I mean is, my field's value is not updating without any action in screen. In order to cope that, should I modify my edit.vm or should I add something in my java code?

I left my script code and logs here;

 

import org.apache.log4j.Level
import org.apache.log4j.Logger

Logger log = Logger.getLogger()
log.setLevel(Level.DEBUG)

def priorityField = getFieldById("priority")
def myField = getFieldByName("myField")

log.debug(myField)

def value = dropdownField.value

log.debug("value = " + value)

if (value == "some value") {
priorityField.setRequired(true)
priorityField.setHidden(false)
}
else {
priorityField.setRequired(false)
priorityField.setHidden(true)
}

 

Logs ; 

Form field ID: customfield_10202, value:

 value    =


All kinds  tips will be helpful.

2 answers

0 votes
Orkun Gedik June 7, 2018

The field I used as "myField" is a dropdown / single select custom field. Also, ı wrote my script inside of Behaviours/Edit Behaviour/Fields/Server side script. @David STOCKY

0 votes
David STOCKY June 7, 2018
Have you ever try to display

myField
.getFormValue() 


Orkun Gedik June 7, 2018

David, thank you for your answer. Yes I tried but there is not any change. 

David STOCKY June 7, 2018
myField .getValue()
Orkun Gedik June 7, 2018

I have tried all of them. The problem is, field's value is not being recognized before any action in current screen. 

David STOCKY June 7, 2018

where did you add your code?

 

On scriptrunner behavious "Initialiser" or "Fields" part concerning a specific field (server side script)

Orkun Gedik June 7, 2018

I added my code inside at server side scripts in Behaviours tab.

David STOCKY June 7, 2018

on which field is our script attached?

Suggest an answer

Log in or Sign up to answer