The subtask creates based on the issue type selected....this works alone but when I add
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Department'}
issue.setCustomFieldValue(cf, "First Line")
in the Additional issue actions in the workflow editor
The subtask isn't created and obviously that custom field isnt updated.
Any ideas?
Thx in advance.
The result evaluated to *assertion error*
assert cfValues['Department'].class == "Open".class | | | | | | Open | false class java.lang.String | class com.atlassian.jira.issue.customfields.option.LazyLoadedOption |
I managed to get it to work.
You can see what I added...
thanks again for the start
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.context.IssueContext import com.atlassian.jira.issue.context.IssueContextImpl import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.customfields.manager.OptionsManager def componentManager = ComponentManager.instance def optionsManager = componentManager.getComponentInstanceOfType(OptionsManager.class) def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Department'} if(cf!=null){ def fieldConfig = cf.getRelevantConfig(issue) def option = optionsManager.getOptions(fieldConfig).find {it.value == "First Line"} issue.setCustomFieldValue(cf, option) }
nice one...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think you are trying to set field value for select list, if yes then try with following code
def customFieldManager = componentManager.getCustomFieldManager() def cf = customFieldManager.getCustomFieldObjectByName("Department"); def optionsManager = ComponentManager.getComponentInstanceOfType(OptionsManager.class) if(cf!=null){ IssueContextImpl issueContext = new IssueContextImpl(issue.getProjectObject(), issue.getIssueTypeObject()); def fieldConfig = cf.getRelevantConfig(issueContext) def option = optionsManager.getOptions(fieldConfig).find {it.value == "First Line"} issue.setCustomFieldValue(cf, option) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you share your code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey again, thanks for the quick reply.
I didn't code much I just used Script Runner built in module in the work flow editor.
I copied your example as is into the additional options.
I'll upload screenshot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any further ideas? if it sa standard text box then this works perfect. but its a drop down.. so I dont know how to modify this to make the drop down be set specifically
def cf = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Department'} issue.setCustomFieldValue(cf, 'my value')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rambranam's code is more or less correct. Do you have a custom field option called "First Line" - case-sensitive?
There are a few examples on this forum on how to set a select list value.
Add some debug lines to make sure you are getting an option value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: componentManager for class: Script75
This is the output from condition tester.. though I'm not sure if this can be tested there
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry Jamie,
I dont have much experience with this code or Jira in general. in reality I won't get much more complex here than populating fields automatically based off the issue type of the parent task.
I'm not sure how to add debug lines.. the syntax to get the information I'm looking for.
the parent task issuetype is "Support"
the subtask issuetype is "Technical Task"
Both screen layouts have the custom field drop down "Department"
I know the code looks sound as you said... I really dont understand why its not working....
looks like I might have to have people just do dupliacte work, add parent.. then manually add subtask with the fields manually being entered :(
Thanks for trying guys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
UPDATE: am getting this error repeatedly in the logs.
Script136.groovy: 5: unable to resolve class IssueContextImpl
@ line 5, column 18.
IssueContextImpl issueContext = new IssueContextImpl(issue.getProjectObject(), issue.getIssueTypeObject());
^
Script136.groovy: 5: unable to resolve class IssueContextImpl
@ line 5, column 33.
IssueContextImpl issueContext = new IssueContextImpl(issue.getProjectObject(), issue.getIssueTypeObject());
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.