LogoLogo
  • ๐Ÿ“‘Introduction
  • ๐Ÿ› ๏ธCookbooks
    • โฑ๏ธExport Issue History
    • ๐Ÿ‘พCreate Jira Issue
    • ๐ŸงฉExtract customfields from issue(s)
    • ๐ŸŒ„Upload Content Attachment
    • ๐ŸšฎCreate Jira ITSM Request
    • ๐ŸšœEdit Jira Issue (Explicit)
    • ๐Ÿš›Edit Jira Issue (Implicit)
    • ๐ŸšŽCreate Jira Workflow
    • ๐Ÿ—ƒ๏ธAdd CustomField to Screen
    • ๐ŸšŸSearch Project Boards
    • ๐Ÿ“…Get User Last-Login Info
    • ๐Ÿค’Remove User Access
    • ๐ŸคฏSuspend User Access
    • ๐ŸฅณRestore User Access
    • ๐Ÿš‹Extract Project Administrators
    • ๐ŸงบSearch Jira User By Email
    • ๐ŸšžSearch Contents By CQL
    • ๐ŸŒŠCascade Permissions from Parent to Child
    • ๐ŸŽญPage Permission Helper
    • ๐Ÿค–Atlassian SCIM Onboarding
    • ๐Ÿ˜ƒCreate User via SCIM
    • ๐Ÿ›ฐ๏ธIssue Permission Helper
  • Jira Software Cloud
    • ๐Ÿ—ƒ๏ธIntroduction
    • ๐Ÿ“ฎAnnouncement Banner
    • ๐Ÿ”Application Roles
    • ๐Ÿ›ก๏ธ Audit records
    • ๐Ÿ“ˆDashboards
    • ๐Ÿ—„๏ธFilters
      • ๐ŸคSharing
    • ๐Ÿ‘ซGroups
    • ๐ŸžIssues
      • ๐Ÿ“ŽAttachments
      • ๐Ÿ“ฌComments
      • ๐ŸƒFields
        • ๐Ÿ–ผ๏ธConfiguration
          • ๐ŸคItems
          • ๐Ÿ”ƒSchemes
        • ๐ŸณContext
          • ๐Ÿ•งOption
        • ๐Ÿ—‘๏ธTrash
      • ๐Ÿท๏ธ Labels
      • ๐Ÿ”—Link
        • ๐Ÿ”ƒRemote
        • ๐Ÿ–‡๏ธTypes
      • ๐Ÿš›Metadata
      • ๐ŸฃPriorities
      • ๐Ÿ€Resolutions
      • ๐Ÿ“ŒSearch
      • ๐Ÿ“ฆType
        • ๐ŸŽดScheme
        • ๐Ÿ›…Screen Scheme
      • ๐Ÿ“ Vote
      • ๐ŸŽฏWatcher
      • ๐Ÿ•ฐ๏ธWorklogs
      • ๐Ÿ“คProperties
      • ๐Ÿ“ญArchiving
    • ๐Ÿ”“Permissions
      • ๐Ÿ“œScheme
        • ๐Ÿ”‘Grant
    • ๐Ÿ“šProjects
      • ๐ŸงฉCategories
      • ๐Ÿ”ฎComponents
      • ๐ŸšงPermission Schemes
      • ๐Ÿ“ฌNotification Schemes
      • ๐Ÿ’ผRoles
        • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘งActors
      • ๐ŸงตTypes
      • ๐ŸงฑVersions
      • ๐Ÿช”Validation
      • ๐Ÿ™ŒFeatures
      • ๐Ÿ“คProperties
    • ๐Ÿ““Screens
      • ๐Ÿ“‚Tabs
        • ๐ŸงฐFields
      • ๐Ÿ“ Schemes
    • โš™๏ธServer
    • ๐Ÿ”ฉJQL
    • โš—๏ธTasks
    • ๐Ÿค“Users
      • ๐Ÿ“ Search
    • ๐Ÿ–จ๏ธWorkflow
      • ๐Ÿš›Scheme
        • ๐Ÿ“ฏIssue Type
      • ๐Ÿ—บ๏ธStatus
    • โš–๏ธMyself
    • ๐Ÿ“Teams
  • Jira Agile
    • ๐Ÿœ๏ธIntroduction
    • ๐Ÿ“‰Boards
      • ๐Ÿ“ƒBacklog
    • ๐Ÿ—“๏ธSprints
    • ๐Ÿ“ˆEpics
  • Jira Service Management
    • ๐Ÿ—บ๏ธIntroduction
    • ๐Ÿ‘จโ€โš–๏ธCustomer
    • โ„น๏ธInfo
    • ๐Ÿ“šKnowledgebase
    • ๐Ÿ›‚Organization
    • ๐Ÿ“™Request
      • ๐ŸšซApproval
      • ๐Ÿ“‚Attachments
      • ๐Ÿ“ฌComments
      • ๐Ÿ“ฎFeedback
      • ๐Ÿ‘ฅParticipants
      • โฐSLA
      • ๐Ÿ’พTypes
      • โš™๏ธService Desk
        • ๐Ÿ›Ž๏ธQueue
    • ๐Ÿ“™Workspaces
  • Jira Assets
    • ๐Ÿ“ Introduction
    • ๐Ÿ‘พIcons
    • ๐Ÿ”ŽAql
    • ๐Ÿ›๏ธObject
      • ๐Ÿ“ Schema
      • ๐ŸงฐType
        • ๐Ÿ›Ž๏ธAttribute
  • Confluence Cloud
    • ๐ŸŽ‘Introduction
    • ๐Ÿ“‰Analytics
    • ๐Ÿ“ขContent
      • ๐ŸŽฎProperties
      • ๐Ÿ“‚Attachments
      • ๐Ÿ“ฌComments
      • ๐ŸšฉLabels
      • ๐ŸŽŽChildren/Descendants
      • ๐Ÿ›ก๏ธPermissions
      • ๐Ÿ”žRestrictions
        • ๐ŸŽ‘Operations
          • ๐Ÿซ‚Group
          • ๐Ÿ‘คUser
      • ๐Ÿ”ƒVersions
    • ๐Ÿ’พSpace
      • ๐Ÿ›ก๏ธPermissions
    • ๐Ÿ”ฐLabel
    • ๐Ÿ”ŽSearch
    • ๐Ÿ–ผ๏ธLong Task
    • ๐Ÿ—ƒ๏ธTemplate
    • ๐ŸŒŠV2
      • ๐Ÿ”๏ธIntroduction
      • ๐ŸงบAttachments
        • ๐Ÿ’ปVersions
      • ๐Ÿ“ƒPage
      • ๐ŸชŸSpace
      • ๐Ÿ—ƒ๏ธCustom Content
  • Atlassian Admin Cloud
    • ๐ŸŒŒIntroduction
    • โ„น๏ธOrganization
      • ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆDirectory
      • ๐Ÿ‘”Policy
    • ๐Ÿ‘ฅUser
      • ๐Ÿ”“Token
    • ๐ŸงฐSCIM
      • ๐Ÿง™โ€โ™‚๏ธUsers
      • โ›น๏ธโ€โ™‚๏ธGroups
      • ๐Ÿ”ฉSchemas
  • Bitbucket Cloud
    • ๐Ÿ‘จโ€๐Ÿ’ปIntroduction
    • ๐Ÿ“ฐWorkspace
      • ๐Ÿ›ก๏ธPermissions
      • ๐Ÿ’พWebhooks
Powered by GitBook
On this page
  • Introduction
  • Extract from a single issue
  • ParseMultiSelectCustomField
  • ParseSelectCustomField
  • ParseCascadingSelectCustomField
  • ParseDatePickerCustomField
  • ParseDateTimeCustomField
  • ParseMultiUserPickerCustomField
  • ParseMultiGroupPickerCustomField
  • ParseFloatCustomField
  • ParseSprintCustomField
  • ParseLabelCustomField
  • ParseMultiVersionCustomField
  • ParseUserPickerCustomField
  • ParseAssetCustomField
  • ParseStringCustomField
  • Extract from multiple issues
  • ParseMultiSelectCustomFields
  • ParseSelectCustomFields
  • ParseCascadingCustomFields
  • ParseMultiUserPickerCustomFields
  • ParseDatePickerCustomFields
  • ParseDateTimeCustomFields
  • ParseMultiGroupPickerCustomFields
  • ParseFloatCustomFields
  • ParseStringCustomFields
  • ParseUserPickerCustomFields
  • ParseSprintCustomFields
  • ParseLabelCustomFields
  • ParseMultiVersionCustomFields
  • ParseAssetCustomFields

Was this helpful?

Export as PDF
  1. Cookbooks

Extract customfields from issue(s)

Introduction

In Jira Cloud, custom fields are managed in a way that allows for flexibility and dynamic creation. Each new custom field that you create within a Jira Cloud instance is assigned a unique ID. This ID is used to identify and manage the custom field's configuration and data within the Jira system.

In this particular case, the library contains multiples helpers method will help you to extract the customfield information by type using the response buffer.

Extract from a single issue

The following methods can be used to extract the customfield information from one issue.

ParseMultiSelectCustomField

This method parses a multi-select custom field from the given buffer data associated with the specified custom field ID and returns a slice of pointers to CustomFieldContextOptionSchema structs.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

options, err := models.ParseMultiSelectCustomField(response.Bytes, "customfield_10046")
if err != nil {
	log.Fatal(err)
}

for _, option := range options {
	fmt.Println(option.ID, option.Value)
}

ParseSelectCustomField

ParseSelectCustomField parses a select custom field from the given buffer data associated with the specified custom field ID and returns a CustomFieldContextOptionScheme struct

_, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

option, err := models.ParseSelectCustomField(response.Bytes, "customfield_10047")
if err != nil {
	log.Fatal(err)
}

fmt.Println(option.ID, option.Value)

ParseCascadingSelectCustomField

This method parses a cascading custom field from the given buffer data associated with the specified custom field ID and returns a CascadingSelectScheme struct pointer.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

cascading, err := models.ParseCascadingSelectCustomField(response.Bytes, "customfield_10045")
if err != nil {
	log.Fatal(err)
}

fmt.Println(cascading.Value, cascading.Child.Value)

ParseDatePickerCustomField

ParseDatePickerCustomField parses the datepicker customfield from the given buffer data associated with the specified custom field ID and returns a struct time.Time value

_, response, err := client.Issue.Get(context.Background(), "KP-24", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

datePicker, err := models.ParseDatePickerCustomField(response.Bytes, "customfield_10040")
if err != nil {
	log.Fatal(err)
}

fmt.Println(datePicker.String())

ParseDateTimeCustomField

ParseDateTimeCustomField parses the datetime customfield from the given buffer data associated with the specified custom field ID and returns a struct time.Time value.

_, response, err := client.Issue.Get(context.Background(), "KP-24", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

datePicker, err := models.ParseDateTimeCustomField(response.Bytes, "customfield_10041")
if err != nil {
	log.Fatal(err)
}

fmt.Println(datePicker.String())

ParseMultiUserPickerCustomField

This method parses a group-picker custom field from the given buffer data associated with the specified custom field ID and returns a slice of pointers to UserDetailScheme structs.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

users, err := models.ParseMultiUserPickerCustomField(response.Bytes, "customfield_10055")
if err != nil {
	log.Fatal(err)
}

for _, user := range users {
	fmt.Println(user.EmailAddress, user.AccountID)
}

ParseMultiGroupPickerCustomField

This method parses a group-picker custom field from the given buffer data associated with the specified custom field ID and returns a slice of pointers to GroupDetailScheme structs.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

groups, err := models.ParseMultiGroupPickerCustomField(response.Bytes, "customfield_10052")
if err != nil {
	log.Fatal(err)
}

for _, group := range groups {
	fmt.Println(group.Name)
}

ParseFloatCustomField

ParseFloatCustomField parses a float custom field from the given buffer data associated with the specified custom field ID and returns string.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

number, err := models.ParseFloatCustomField(response.Bytes, "customfield_10043")
if err != nil {
	log.Fatal(err)
}

fmt.Println(number)

ParseSprintCustomField

ParseSprintCustomField parses a sprints custom field from the given buffer data associated with the specified custom field ID and returns a slice of the SprintDetailScheme struct.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

sprints, err := models.ParseSprintCustomField(response.Bytes, "customfield_10020")
if err != nil {
	log.Fatal(err)
}

for _, sprint := range sprints {
	fmt.Println(sprint.ID)
}

ParseLabelCustomField

ParseLabelCustomField parses a textfield slice custom field from the given buffer data associated with the specified custom field ID and returns string slice.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

labels, err := models.ParseLabelCustomField(response.Bytes, "customfield_10042")
if err != nil {
	log.Fatal(err)
}

for _, label := range labels {
	fmt.Println(label)
}

ParseMultiVersionCustomField

ParseMultiVersionCustomField parses a version-picker custom field from the given buffer data associated with the specified custom field ID and returns a slice of pointers to VersionDetailScheme structs.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

versions, err := models.ParseMultiVersionCustomField(response.Bytes, "customfield_10067")
if err != nil {
	log.Fatal(err)
}

for _, version := range versions {
	fmt.Println(version.ID, version.Name, version.Description)
}

ParseUserPickerCustomField

ParseUserPickerCustomField parses a user custom field from the given buffer data associated with the specified custom field ID and returns a struct of UserDetailScheme.

_, response, err := client.Issue.Get(context.Background(), "KP-24", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

user, err := models.ParseUserPickerCustomField(response.Bytes, "customfield_10051")
if err != nil {
	log.Fatal(err)
}

fmt.Println(user.EmailAddress)
fmt.Println(user.DisplayName)
fmt.Println(user.AccountID)
fmt.Println(user.AccountType)

ParseAssetCustomField

ParseAssetCustomField parses the Jira assets elements from the given buffer data associated with the specified custom field ID and returns a struct CustomFieldAssetScheme slice.

issue, response, err := client.Issue.Get(context.Background(), "KP-23", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

assets, err := models.ParseAssetCustomField(response.Bytes, "customfield_10068")
if err != nil {
	log.Fatal(err)
}

for _, asset := range assets {
	fmt.Println(asset.Id, asset.WorkspaceId, asset.ObjectId)
}

ParseStringCustomField

ParseStringCustomField parses a textfield custom field from the given buffer data associated with the specified custom field ID and returns string.

_, response, err := client.Issue.Get(context.Background(), "KP-24", nil, []string{"transitions"})
if err != nil {
	log.Fatal(err)
}

textField, err := models.ParseStringCustomField(response.Bytes, "customfield_10049")
if err != nil {
	log.Fatal(err)
}

fmt.Println(textField)

Extract from multiple issues

If you want to extract the customfield values from a buffer of issues, you can use the following methods, it returns a map where the key is the issue key and the value is the customfield values parsed

ParseMultiSelectCustomFields

ParseMultiSelectCustomFields extracts and parses multi-select custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of CustomFieldContextOptionScheme structs, representing the parsed multi-select custom field values.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10046"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

multiSelectOptions, err := models.ParseMultiSelectCustomFields(response.Bytes, "customfield_10046")
if err != nil {
	log.Fatal(err)
}

for issue, options := range multiSelectOptions {
	for _, option := range options {
		fmt.Println(issue, option.ID, option.Value)
	}
}

ParseSelectCustomFields

ParseSelectCustomFields extracts and parses select custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a CustomFieldContextOptionScheme struct, representing the parsed select custom field value.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10047"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseSelectCustomFields(response.Bytes, "customfield_10047")
if err != nil {
	log.Fatal(err)
}

for issue, option := range customfields {
	fmt.Println(issue, option.ID, option.Value)
}

ParseCascadingCustomFields

ParseCascadingCustomFields extracts and parses a cascading custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a CascadingSelectScheme struct pointer, representing the parsed cascading custom field value.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10045"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseCascadingCustomFields(response.Bytes, "customfield_10045")
if err != nil {
	log.Fatal(err)
}

for issue, value := range customfields {
	fmt.Println(issue, value.Value, value.Child.Value)
}

ParseMultiUserPickerCustomFields

ParseMultiUserPickerCustomFields extracts and parses a user picker custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of UserDetailScheme structs, representing the parsed multi-select custom field values.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10055"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseMultiUserPickerCustomFields(response.Bytes, "customfield_10055")
if err != nil {
	log.Fatal(err)
}

for issue, users := range customfields {

	for _, user := range users {
		fmt.Println(issue, user.AccountID, user.DisplayName)
	}
}

ParseDatePickerCustomFields

ParseDatePickerCustomFields extracts and parses the datepicker customfield data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a time.Time value, representing the parsed datepicker values with the Jira issues.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10040"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseDatePickerCustomFields(response.Bytes, "customfield_10040")
if err != nil {
	log.Fatal(err)
}

for issue, datepicker := range customfields {
	fmt.Println(issue, datepicker.String())
}

ParseDateTimeCustomFields

ParseDateTimeCustomFields extracts and parses the datetime customfield data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a time.Time value, representing the parsed datetime values with the Jira issues.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10041"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseDateTimeCustomFields(response.Bytes, "customfield_10041")
if err != nil {
	log.Fatal(err)
}

for issue, datetime := range customfields {
	fmt.Println(issue, datetime.String())
}

ParseMultiGroupPickerCustomFields

ParseMultiGroupPickerCustomFields extracts and parses a group picker custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of GroupDetailScheme structs, representing the parsed multi-group custom field values.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10052"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseMultiGroupPickerCustomFields(response.Bytes, "customfield_10052")
if err != nil {
	log.Fatal(err)
}

for issue, groups := range customfields {
	for _, group := range groups {
		fmt.Println(issue, group.Name, group.GroupID)
	}
}

ParseFloatCustomFields

ParseFloatCustomFields extracts and parses the float customfield information from multiple issues using a bytes.Buffer.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a string representing the parsed float64 customfield value.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10043"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseFloatCustomFields(response.Bytes, "customfield_10043")
if err != nil {
	log.Fatal(err)
}

for issue, number := range customfields {
	fmt.Println(issue, number)
}

ParseStringCustomFields

ParseStringCustomFields extracts and parses the textfield customfield information from multiple issues using a bytes.Buffer.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a string representing the parsed textfield customfield value.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10049"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseStringCustomFields(response.Bytes, "customfield_10049")
if err != nil {
	log.Fatal(err)
}

for issue, textField := range customfields {
	fmt.Println(issue, textField)
}

ParseUserPickerCustomFields

ParseUserPickerCustomFields extracts and parses a user custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a UserDetailScheme struct pointer ,representing the parsed user custom field value.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10051"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseUserPickerCustomFields(response.Bytes, "customfield_10051")
if err != nil {
	log.Fatal(err)
}

for issue, user := range customfields {
	fmt.Println(issue, user.AccountID)
}

ParseSprintCustomFields

ParseSprintCustomFields extracts and parses sprint custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of SprintDetailScheme structs, representing the parsed sprint custom field values.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10020"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseSprintCustomFields(response.Bytes, "customfield_10020")
if err != nil {
	log.Fatal(err)
}

for issue, sprints := range customfields {

	for _, sprint := range sprints {
		fmt.Println(issue, sprint.Name, sprint.ID, sprint.BoardID, sprint.State)
	}
}

ParseLabelCustomFields

ParseLabelCustomFields extracts and parses the label customfield information from multiple issues using a bytes.Buffer.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a string slice representing the parsed label customfield value.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10042"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseLabelCustomFields(response.Bytes, "customfield_10042")
if err != nil {
	log.Fatal(err)
}

for issue, labels := range customfields {
	fmt.Println(issue, labels)
}

ParseMultiVersionCustomFields

ParseMultiVersionCustomFields extracts and parses a version picker custom field data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of VersionDetailScheme structs, representing the parsed multi-version custom field values.

  • The JSON data within the buffer is expected to have a specific structure where the custom field values are organized by issue keys and options are represented within a context.

  • The function parses this structure to extract and organize the custom field values.

  • If the custom field data cannot be parsed successfully, an error is returned.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10067"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseMultiVersionCustomFields(response.Bytes, "customfield_10067")
if err != nil {
	log.Fatal(err)
}

for issue, versions := range customfields {

	for _, version := range versions {
		fmt.Println(issue, version.Name, version.ID)
	}
}

ParseAssetCustomFields

ParseAssetCustomFields extracts and parses jira assets customfield data from a given bytes.Buffer from multiple issues.

This function takes the name of the custom field to parse and a bytes.Buffer containing JSON data representing the custom field values associated with different issues. It returns a map where the key is the issue key and the value is a slice of CustomFieldAssetScheme structs, representing the parsed assets associated with a Jira issues.

_, response, err := client.Issue.Search.Post(context.Background(), "project = KP", []string{"customfield_10072"}, nil, 0, 50, "")
if err != nil {
	log.Fatal(err)
}

customfields, err := models.ParseAssetCustomFields(response.Bytes, "customfield_10072")
if err != nil {
	log.Fatal(err)
}

for issue, assets := range customfields {

	for _, asset := range assets {
		fmt.Println(issue, asset.Id, asset.WorkspaceId, asset.ObjectId)
	}
}
PreviousCreate Jira IssueNextUpload Content Attachment

Last updated 11 months ago

Was this helpful?

๐Ÿ› ๏ธ
๐Ÿงฉ
Page cover image