Skip to content

Instantly share code, notes, and snippets.

@tdalon
Last active December 24, 2023 18:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdalon/254a1daa1990d22aa55b82dae7a03be3 to your computer and use it in GitHub Desktop.
Save tdalon/254a1daa1990d22aa55b82dae7a03be3 to your computer and use it in GitHub Desktop.
How to Get Jira Issue Field Value in PowerQuery M
(FieldName as text) as text =>
let
Source = Json.Document(Web.Contents(JiraRootUrl & "/rest/api/latest/field")),
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"ExpandedTable" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "name"}, {"id", "name"}),
Record = Table.First(Table.SelectRows(ExpandedTable, each ([name] = FieldName))),
FieldId = Record.Field(Record,"id")
in
FieldId
(IssueKey as text, FieldName as text) =>
let
FieldId = JiraFieldName2Id(FieldName),
Source = Json.Document(Web.Contents(JiraRootUrl & "/rest/api/2/issue/" & IssueKey & "?fields=" & FieldId)),
fields = Source[fields],
Field = Record.Field(fields,FieldId),
FieldValue = if Field = null then null else Record.Field(Field,"value")
in
FieldValue
@tdalon
Copy link
Author

tdalon commented Jun 30, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment