Hello dear gurus
Is there a way to set value of a custom field based on other field? I know it's possible but i need to add value, not to replace it with new one. For example - a field that stores all usernames who become assignees of the issue.
What code are you proposing to use to do this?
It will need to read the current multi-user picker contents and add the new one to the list.
I was trying to use something like scripted field from Groovy Runner (there is an example in comments of https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted+Fields#ScriptedFields-Aninformationmessagebut it refers to select list from linked issues and i was not able to change the code for my case).
Ok, so what have you got in your code so far? Just the bit that tries to read the current values, build the new set and post it back?
This is the code I got:
import com.atlassian.jira.ComponentManagerimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.issue.CustomFieldManagerCustomFieldManager customFieldManager = componentManager.getCustomFieldManager()def componentManager = ComponentManager.getInstance()def executioners = "" def cf = issue.assigneeUser executioners += getCustomFieldValue(cf) + " "
But it returns [null]. I see that my code is wrong but I don't get how to add value to the field. I tried to change field type from "Text Searcher" to "User Picker" - of course it shows [Anonymous]
It's not the searcher, that only defines how it's indexed and searched, and you can't just "change field type".
I am assuming that
Your code is broadly correct until the very last line. That line won't work because it's a simple "concatenate" or "add" operation and you're not working with strings or numbers. You're actually working with a user object and an array of users from the multiselect.
Executioners should be set by saying something like "executioners = getCustomFieldValue(cf).add(issue.assigneeUser)"
("Executioners" is an interesting choice of words by the way. It is correct, but in English, is only really used to describe "a person who legally kills criminals on the behalf of the government", we rarely use it to say "someone who did something", even though we do say "this procedure was executed")
It looks like you're new here. Sign in or register to get started.