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

How whe can get custom fields values? #417

Open
erdvillegasoxxo opened this issue Nov 13, 2021 · 7 comments
Open

How whe can get custom fields values? #417

erdvillegasoxxo opened this issue Nov 13, 2021 · 7 comments
Labels
needs triage Ticket that needs triage (a proper look for classification)

Comments

@erdvillegasoxxo
Copy link

Hi team,

Recently we are creating a custom app that consume JIRA data, whe need to get values trhought custom fields, can you help me with an example of how can I read the values from that fields.

I using thise example:

func crearCSV(issues []jira.Issue) {

	file, err := os.Create("result.csv")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	w := csv.NewWriter(file)
	w.Comma = ','
	defer w.Flush()

	w.Write([]string{"IssueKey,IssueType,ProjectKey,Summary"})
	checkError(err)

	for _, i := range issues {

		a, _ := i.Fields.Unknowns.Value("customfield_10061")
		fmt.Printf("%#v", a)

	}

}
@github-actions
Copy link

Hi! Thank you for taking the time to create your first issue! Really cool to see you here for the first time. Please give us a bit of time to review it.

@evilnerd
Copy link
Contributor

The thing you're looking for is jira.Issue.GetCustomFields(issueKey) - this returns a map with custom field values where the key is the field's internal name.

If you want to map the 'user friendly' name to the internal name, I recommend you use jira.Client.Field.GetList(), to build a 'translation' map (which is also safer, since the internal name is not guaranteed to be the same if you have e.g. a test and prod version of Jira)

	fields, _, err := jira.Client.Field.GetList()
	if err != nil {
		return fmt.Errorf("unable to get the list of fields: %w", err)
	}

	jira.fieldMapping = make(map[string]string)

	for _, f := range fields {
		if f.Custom {
			jira.fieldMapping[f.Name] = f.ID
		}
	}

@erdvillegasoxxo
Copy link
Author

Thanks for the example, as I try it, I let you know the results. Thanks a lot!

@erdvillegasoxxo
Copy link
Author

Thanks for your help

@andygrunwald andygrunwald reopened this Feb 26, 2022
@andygrunwald
Copy link
Owner

@erdvillegasxpt Would you be able to prepare a pull request to extend the docs?

@erdvillegasoxxo
Copy link
Author

Sure, let me write the note and I'll send a PR

@andygrunwald andygrunwald added the needs triage Ticket that needs triage (a proper look for classification) label Aug 20, 2022
@andygrunwald
Copy link
Owner

Hey,

I am very sorry that this issue has been open for a long time with no final solution. We work on this project in our spare time, and sometimes, other priorities take over. This is the typical open source dilemma.

However, there is news: We are kicking off v2 of this library 🚀

To provide visibility, we created the Road to v2 Milestone and calling for your feedback in #489

The development will take some time; however, I hope you can benefit from the changes.
If you seek priority development for your issue + you like to sponsor it, please contact me.

What does this mean for my issue?

We will work on this issue indirectly.
This means that during the development phase, we aim to tackle it.
Maybe in a different way like it is currently handled.
Please understand that this will take a while because we are running this in our spare time.

Final words

Thanks for using this library.
If there is anything else you would like to tell us, let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Ticket that needs triage (a proper look for classification)
Projects
None yet
Development

No branches or pull requests

3 participants