
๐๏ธAdd CustomField to Screen
In this article, I would be showing you how to add custom-fields on a Jira project screens using go-atlassian. Before we get started, let's first understand the Jira entities involved in this process: screens, screen tabs, and screen tab fields.
Screens:
Screens in Jira define the layout and configuration of different views, such as issue creation, editing, and viewing.
Each screen consists of one or more screen tabs.
Screen Tabs:
Screen tabs are sections within a screen that group related fields together.
A screen can have multiple screen tabs, and each tab can contain multiple fields.
Screen Tab Fields:
Screen tab fields are the individual fields (e.g., standard or custom fields) displayed within a screen tab.
Step 1: Create a new Go project
Create a new directory for your project and navigate to it in your terminal or command prompt. Initialize a new Go module using the following command:
go mod init your-module-nameStep 2: Install the "go-atlassian" library
To use the "go-atlassian" library, you need to install it as a dependency in your project. Run the following command:
go get github.com/ctreminiom/go-atlassianStep 3: Import the required packages
Create a new Go file, e.g., main.go, and import the necessary packages:
Step 4: Set up Jira API client
Initialize the Jira API client with your Jira base URL and API token:
Step 5: Extract the issue type screen scheme
Before to add the customfields on the project screens, we need to search the issue type screen scheme associated with a Jira project, then iterates the mapping to extract the screen schemes linked. In this particular example, we're going to add the following customfields on the KP project:
Start Date
customfield_10068Sprint
customfield_10020DueDate
duedatetimeTracking
timetrackingEnvironment
customfield_10069Category
customfield_10070Testing By
customfield_10071
Use the following code to extract the issue type screen scheme linked to the KP project.
Step 6: Extract the screen schemes
With the Issue Type Screen Scheme ID extracted from the previous step, we can proceed with the screen scheme extraction, use the following code to extract the screen schemes
Step 7: Extract the screen IDs
The next step is extract the screen ID's from the screen schemes, you can use this code to extract the screen IDs.
Step 8: Add the fields on the project screens
The final step is add the custom-fields on the screen default tabs, it's required to validate if the customfield is already added on the screen tab, if not, add the custom-field on the screen and log the result.
We can use the following code below:
When you run the code, the custom-fields selected will be available on the project ๐๐.


Last updated
Was this helpful?