Page cover

๐Ÿ““Screens

This resource represents the screens used to record issue details

Get screens for a field

GET /rest/api/{2-3}/field/{fieldId}/screens

Returns a paginated list of the screens a field is used in.

package main

import (
	"context"
	_ "github.com/ctreminiom/go-atlassian/v2/jira/v3"
	"github.com/ctreminiom/go-atlassian/v2/jira/v2"
	"log"
	"os"
)

func main() {

	/*
		----------- Set an environment variable in git bash -----------
		export HOST="https://ctreminiom.atlassian.net/"
		export MAIL="MAIL_ADDRESS"
		export TOKEN="TOKEN_API"

		Docs: https://stackoverflow.com/questions/34169721/set-an-environment-variable-in-git-bash
	*/

	var (
		host  = os.Getenv("HOST")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v2.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	var (
		fieldID   = "customfield_10014"
		startAt   = 0
		maxResult = 50
	)

	screens, response, err := atlassian.Screen.Fields(context.Background(), fieldID, startAt, maxResult)
	if err != nil {
		log.Fatal(err)
	}

	log.Println("Response HTTP Code", response.Code)
	log.Println("HTTP Endpoint Used", response.Endpoint)

	for _, screen := range screens.Values {
		log.Println(screen.ID, screen.Name, screen.Description)
	}
}

Get screens

GET /rest/api/{2-3}/screens

Returns a paginated list of all screens or those specified by one or more screen IDs.

Create screen

POST /rest/api/{2-3}/screens

Creates a screen with a default field tab.

Add field to default screen

POST /rest/api/{2-3}/screens/addToDefault/{fieldId}

Adds a field to the default tab of the default screen.

Update screen

PUT /rest/api/{2-3}/screens/{screenId}

Updates a screen. Only screens used in classic projects can be updated.

Delete screen

DELETE /rest/api/{2-3}/screens/{screenId}

Deletes a screen. A screen cannot be deleted if it is used in a screen scheme, workflow, or workflow draft. Only screens used in classic projects can be deleted.

Get available screen fields

GET /rest/api/{2-3}/screens/{screenId}/availableFields

Returns the fields that can be added to a tab on a screen.

Last updated

Was this helpful?