Hi all,
I'm using the below groovy script to set the issue summary of a sub-task to the value of "Product" (a cascading select field in the same sub-task) on create. (I took snippets from https://answers.atlassian.com/questions/197938/getting-first-value-from-cascading-select-custom-fieldbut it doesn't seem to be working).
Any suggestions are much appreciated!
import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.customfields.view.CustomFieldParams import com.atlassian.jira.issue.customfields.option.Option Issue issue = issue; ComponentManager componentManager = ComponentManager.getInstance(); CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField customField = componentManager.getCustomFieldManager().getCustomFieldObjectByName("Product"); Object productValue = issue.getCustomFieldValue(customField)?.getValue(); CustomFieldParams params = (CustomFieldParams) productValue; if (params != null) { Object parent = params.getFirstValueForNullKey(); Object child = params.getFirstValueForKey("1"); } issue.summary = issue.summary + productValue;
I have used below code to get the value from single group picker field. This may give you some hint:
def cfg = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Assignment Group"}
def cfgvalue =(List<Group>)issue.getCustomFieldValue(cfg)
String Agroup = ""
for(Group group:cfgvalue){
Agroup = group.getName()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.