Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-794]: Fixed the issue of fields not prefilled when creating issue with custom fields #1127

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
32 changes: 24 additions & 8 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,30 @@ func MakeCreateIssueURL(instance Instance, project *jira.Project, issue *jira.Is
}

// add custom fields
for k, v := range issue.Fields.Unknowns {
strV, ok := v.(string)
if ok {
q.Add(k, strV)
}
if mapV, ok := v.(map[string]interface{}); ok {
if id, ok := mapV["id"].(string); ok {
q.Add(k, id)
for key, field := range issue.Fields.Unknowns {
switch fieldTyped := field.(type) {
case string: // handles fields like url, short text, paragraph
q.Add(key, fieldTyped)
case map[string]interface{}: // handles fields like dropdown
if id, ok := fieldTyped["id"].(string); ok {
q.Add(key, id)
}
case []interface{}: // handles fields like labels, checkbox, flags
for _, element := range fieldTyped {
raghavaggarwal2308 marked this conversation as resolved.
Show resolved Hide resolved
switch elementTyped := element.(type) {
case string:
q.Add(key, elementTyped)
case map[string]interface{}:
if id, ok := elementTyped["id"].(string); ok {
q.Add(key, id)
}
case []map[string]interface{}:
for _, mapWithID := range elementTyped {
if id, ok := mapWithID["id"].(string); ok {
q.Add(key, id)
}
}
}
}
}
}
Expand Down
Loading