pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.96k stars 874 forks source link

Get only visible fields #1898

Open nitrocode opened 2 months ago

nitrocode commented 2 months ago

Problem trying to solve

I want to be able to set custom fields as required in jira tickets but only if that field is exposed in the UI.

For PLATFORM project tickets, the field may be editable and in GRAPH project the field may not be editable.

At the moment, I use the following

jira = JIRA('https://org.atlassian.net/', basic_auth=(jira_user, jira_token))
issue = jira.issue(ticket)
issue.fields

and issue.fields returns all the fields

There is also

meta = jira.editmeta(ticket)

However, this also shows me all the fields.

If the field does not have a value or is uneditable, the value will default to None which isn't helpful.

Possible solution(s)

Looking for one.

Maybe it can figure out the project name, check the view of the project, see what fields are exposed, and then we'll know which fields are editable.

Alternatives

Additional Context

Zhengchai commented 2 months ago

vote for this issue also, please consider to add the navigable support during the search_tickets(fields=navigable) etc.

nitrocode commented 2 months ago

There does seem to be a way to do this but you need administrator privileges in order to access the jira screens, then you can get the screen for the project, and finally retrieve all the visible fields. It's possible that jira doesn't output the visibility unless navigating to screens.