๐Ÿ““
Screens
This resource represents the screens used to record issue details

Get screens for a field

Returns a paginated list of the screens a field is used in.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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

Returns a paginated list of all screens or those specified by one or more screen IDs.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/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 (
screenIDs = []int{10000}
startAt = 0
maxResults = 0
)
screens, response, err := atlassian.Screen.Gets(context.Background(), screenIDs, startAt, maxResults)
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)
}
}

Create screen

Creates a screen with a default field tab.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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)
โ€‹
newScreen, response, err := atlassian.Screen.Create(context.Background(), "FX Screen", "sample description")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Printf("The new screen has been created with the ID %v", newScreen.ID)
}

Add field to default screen

Adds a field to the default tab of the default screen.
package main
import (
"context"
"github.com/ctreminiom/go-atlassian/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)
response, err := atlassian.Screen.AddToDefault(context.Background(), "customfield_xxxx")
if err != nil {
log.Fatal(err)
}
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}

Update screen

Updates a screen. Only screens used in classic projects can be updated.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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)
โ€‹
screenUpdated, response, err := atlassian.Screen.Update(context.Background(), 10015, "AX Screen", "")
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
log.Println(screenUpdated)
}

Delete screen

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.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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)
โ€‹
response, err := atlassian.Screen.Delete(context.Background(), 10015)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
}

Get available screen fields

Returns the fields that can be added to a tab on a screen.
package main
โ€‹
import (
"context"
"github.com/ctreminiom/go-atlassian/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)
โ€‹
fields, response, err := atlassian.Screen.Available(context.Background(), 10000)
if err != nil {
log.Fatal(err)
}
โ€‹
log.Println("Response HTTP Code", response.Code)
log.Println("HTTP Endpoint Used", response.Endpoint)
โ€‹
for _, field := range fields {
log.Println(field.ID, field.Name)
}
}
Last modified 9mo ago
Export as PDF
Copy link
On this page
Get screens for a field
Get screens
Create screen
Add field to default screen
Update screen
Delete screen
Get available screen fields