Created
August 21, 2025 13:46
-
-
Save vikrantyadav11/50adf47de1cb6a87aeea5c62c8d16a04 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Retrieve the current context and issue key | |
| const context = await getContext(); | |
| const issueKey = context.extension.issue.key; | |
| // Access the fix version field. Replace this with your own custom field Id if needed. | |
| const fixVersionField = getFieldById("fixVersions"); | |
| // Attempt to fetch the current issue data | |
| try { | |
| const res = await makeRequest(`/rest/api/3/issue/${issueKey}`); | |
| const currentStatus = res.body.fields.status.name; | |
| // List of statuses where the Fix Version field should be read-only | |
| const restrictedStatuses = [ | |
| "Ready for Merge", | |
| "Merged", | |
| "Ready for Production", | |
| "UAT", | |
| "Closed" | |
| ]; | |
| // Determine if the field should be read-only | |
| const restrictFixVersionEditing = restrictedStatuses.includes(currentStatus); | |
| // Set the field to read-only based on the status | |
| fixVersionField.setReadOnly(restrictFixVersionEditing); | |
| } catch (error) { | |
| // Log any errors encountered during the request | |
| logger.error(`Failed to retrieve issue data for ${issueKey}: ${error}`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment