I have a transition screen from which I am getting values(s) via a checkbox control, I need to get these values and update them on another checkbox control in the issues view screen. I tried the below code and it worked but it doesnt set the checkbox option as selected but just shows the value like a editable text but when I clicked edit that option is not selected.
def changeHolder = new DefaultIssueChangeHolder() custField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(custField), platvalue),changeHolder)
I read that you need to use options , so I used the below code but it doesnt work
def optionsManager = ComponentAccessor.getOptionsManager() def config = platRelOnAPIField.getRelevantConfig(issue) def options = optionsManager.getOptions(config) log.debug("Options of Plat rel on field in API:"+options) // This prints properly def newOption = options.get(7) //I want to set to the 8th checkbox just for example,this value prints properly ModifiedValue mVal = new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField),newOption); platRelOnAPIField.updateValue(null, issue, mVal, new DefaultIssueChangeHolder());
But I end up with this exception
java.lang.ClassCastException: com.atlassian.jira.issue.customfields.option.LazyLoadedOption cannot be cast to java.util.Collection
I am a newbie to groovy/jira apis , so please can someone help me to set the checkbox value properly for the customfield
Ive checked this
but I still get the same exception :(
Thanks !
A checkbox is an array of options - consider the list:
There, it's got three options selected, so the value of the field is actually a collection of three. You need to place the option you want into a collection of options to pass into the field, even if you only have one option to select.
Ok. Now I have a collection of options called platvalue which holds the values I want to update and this statement works
custField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(custField), platvalue),changeHolder)
but it doesnt check the checkboxes for those values for my custField(one to be updated), here
platvalue = issue.getCustomFieldValue(platRelOnField) //platRelOnField is the field from where I am getting my values to be set
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a step forward, the next question is about what you see in the logs when this stuff runs. If it's not updating anything, I'd expect an error message that at least hints at the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked for any error in the logs, there are no errors as such :( Don't know where I am going wrong. The values are shown against the field but the checkboxes remain unchecked.
However, I find this line
[webpanels.children.condition.ChildIssuesPanelVisibilityCondition]Exception when evaluating if child issues panel should be displayed
But I dont think it has anything to do with my code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, you'll have to go into quite a bit of debugging now. I'm not sure what's wrong (unless the code you've not shown us here is somehow blanking out the field data you're trying to put into the change), but I'd check the values of variables on each line until you find out where the nulls/empty data is coming from.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I managed to get this working with the below code
ArrayList<LazyLoadedOption> optionsList = new ArrayList<LazyLoadedOption>(); FieldConfig fieldConfig = platRelOnAPIField.getRelevantConfig(issue); OptionsManager optionManager = ComponentAccessor.getOptionsManager(); platOptions = optionManager.getOptions(fieldConfig); for(def i = 0;i<platOptions.size();i++){ def optVal = platOptions.get(i).getValue(); if(platOptions.get(i).getValue().equals("custom field value")){ optionsList.add(platOptions.get(i)); break; } }
Now I have optionsList which I pass like before to updateValue
platRelOnAPIField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(platRelOnAPIField), optionsList),changeHolder)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.