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
@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].",
const uacField = getFieldById("customfield_10322");
uacField.setRequired(true);
const mobileField = getFieldById("customfield_10323");
mobileField.setVisible(false);
mobileField.setRequired(false);
const productareaField = getFieldById("customfield_10536");
productareaField.setVisible(false);
@vikrantyadav11
vikrantyadav11 / Set Issue Assignee Based on Select List Field Value.groovy
Last active June 26, 2025 14:18
Jira Cloud Scripted Listner to set Assignee based on Select List Field
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
def eventIssue = Issues.getByKey(issue.key as String)
def issueKey = eventIssue.key
// Correctly extract the custom field value
def rawProductArea = eventIssue.getCustomFieldValue("Product Area")
def productAreaValue = rawProductArea instanceof Map ? rawProductArea.value : rawProductArea?.toString()
logger.info("Product Area = ${productAreaValue}")
def eventIssue = Issues.getByKey(issue.key as String)
// Construct JQL query
def jqlQuery = "issue in linkedIssues(\"${eventIssue.key}\") AND project = \"MTP\""
// Run search using the latest API
def searchResult = get("/rest/api/3/search/jql")
.queryString("jql", jqlQuery)
.queryString("fields", "summary,key,status")
.queryString("maxResults", "50") // adjust as needed
@vikrantyadav11
vikrantyadav11 / Hide_Unhide Field on Transition Screen Based on Dropdown field Value.groovy
Created June 9, 2025 04:22
Hide/Unhide Field on Transition Screen Based on Dropdown field Value ( Jira Cloud)
const transitionId = await getContext().then(context => context.extension.issueTransition.id);
const releaseNotesField = getFieldById("customfield_10324");
releaseNotesField.setVisible(false)
// Get the custom field (10323) that controls the logic (Yes/No)
const changeField = getFieldById("customfield_10323");
const changeFieldValue = changeField.getValue().value
// Check condition: if transitioned to Done and changeField value is "Yes"
if (transitionId == 21 && changeFieldValue == "Yes") {
@vikrantyadav11
vikrantyadav11 / Allow Certain User to Transition Issue.groovy
Created May 22, 2025 07:13
Allow Certain User to Transition Issue in Scriptruner for Jira Cloud
['accountID', 'accountID'].includes(user.accountId)
import requests
import os
import csv
# Confluence credentials and domain
JIRA_DOMAIN = "https://your_domain.atlassian.net"
EMAIL = os.getenv("JIRA_EMAIL", "EMAIL_ADDRESS")
API_TOKEN = os.getenv("JIRA_API_TOKEN", "API_TOKEN")
# Headers for authentication
@vikrantyadav11
vikrantyadav11 / Get Users in Atlassian Cloud Instance.py
Created March 25, 2025 11:20
Get Users in Atlassian Cloud Instance Along with Last Active Date
import requests
import csv
# Constants
ORG_ID = "YOUR_ORG_ID"
BASE_URL = f"https://api.atlassian.com/admin/v1/orgs/{ORG_ID}/users"
BEARER_TOKEN = "your_bearer_token_here" # Replace with your actual token
HEADERS = {
"Authorization": f"Bearer {BEARER_TOKEN}",
"Accept": "application/json"
def fieldsResponse = get('/rest/api/2/field').asObject(List).body
def fieldCounts = [:]
fieldsResponse.each { field ->
def fieldId = field.id
def fieldName = field.name
def fieldType = field.schema?.type ?: 'N/A'
def jqlQuery
if (fieldId.startsWith('customfield_')) {
// Retrieve the list of projects
def projectsResponse = get('/rest/api/2/project').asObject(List).body
def fieldMappings = [:]
projectsResponse.each { project ->
def projectId = project.id
def projectName = project.name
// Retrieve the list of screens for the project