Skip to content

Instantly share code, notes, and snippets.

View vikrantyadav11's full-sized avatar
🏠
Working from home

vikrantyadav11

🏠
Working from home
View GitHub Profile
// Get Story Points field ID
def storyPointsField = get("/rest/api/3/field")
.asObject(List)
.body
.find { it.name == "Story Points*" }
.id
// Cast issue.key to String
def eventIssue = Issues.getByKey(issue.key as String)
def issueType = eventIssue.issueType.name
import groovy.json.JsonOutput
def fieldId= "customfield_10083" // Id of the custom field that needs new options
def contextId = "10193" // Context associated with the field
// List of option values to be added to the custom field
def optionValueList = ["1","2","3"]
// Payload with the options (for the POST request that will add them as field options)
optionValueList.each
// Get Story Points field ID
def storyPointsField = get("/rest/api/3/field")
.asObject(List)
.body
.find { it.name == "Story Points" }
.id
logger.info("Story Point ID : ${storyPointsField}")
// Cast issue.key to String
// Get Story Points field ID
def storyPointsField = get("/rest/api/3/field")
.asObject(List)
.body
.find { it.name == "Story Points" }
.id
// Cast issue.key to String
def eventIssue = Issues.getByKey(issue.key as String)
def issueType = eventIssue.issueType.name
// 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}`);
import requests
import csv
# Jira credentials (hardcoded for now)
EMAIL = "[email protected]"
API_TOKEN = "your_api_token"
BASE_URL = "https://YOU_DOMAIN.atlassian.net/rest/api/3"
AUTH = (EMAIL, API_TOKEN)
HEADERS = {"Accept": "application/json"}
// Script Listener for Customer Facing Verbatim Field Updates
// Configure as "Issue Updated" event listener
// Get the updated issue
def issueKey = issue.key as String
def hapiIssue = Issues.getByKey(issueKey)
// Check if "Customer facing Verbatim" field was updated
def changelogItems = changelog.items
def customerFacingVerbatimChanged = changelogItems.find { item ->
item.field == "Customer facing Verbatim"
}
import groovy.json.JsonOutput
import java.text.SimpleDateFormat
// Step 1: Get version ID from the event
def versionData = binding.variables.version as Map
def versionId = versionData?.id
if (!versionId) {
logger.warn("⚠️ Version ID not found in binding. Skipping sync.")
return
}
// Cast version object from binding to a Map
def versionData = binding.variables.version as Map
if (versionData) {
def name = versionData['name'] ?: "N/A"
def description = versionData['description'] ?: "N/A"
def released = versionData['released']
def archived = versionData['archived']
def overdue = versionData['overdue']
def projectId = versionData['projectId']
@vikrantyadav11
vikrantyadav11 / Set Default for Single Line text field.groovy
Created July 8, 2025 07:58
Set Default for Single Line text field based on dropdown field selection
const customerFacingVarbatimField = getFieldById("customfield_27449");
const customerFacingVarbatimFieldValue = customerFacingVarbatimField.getValue()?.value;
const responseField = getFieldById("customfield_20579");
const responses = {
"Fix Released": "The issue has been fixed in [Version X.Y.Z] released on [Date]. Please upgrade to apply the fix.",
"Fix in Progress": "Actively working on a fix, expected in our upcoming patch [on Date].",
"Under Investigation": "The issue/request is under investigation. Updates will follow.",
"Workaround Provided": "[Share workaround].",