Bhavya-org / Scripts

0 stars 0 forks source link

Organization add if reporter is in the group #56

Open Bhavya-ss opened 1 week ago

Bhavya-ss commented 1 week ago

def issueKey = issue.key def reporterAccountId = issue.fields.reporter?.accountId def groupName = "jira-servicemanagement-users-bhavyass"

def groupsResponse = get("/rest/api/3/user?accountId=${reporterAccountId}&expand=groups") .header('Content-Type', 'application/json') .asObject(Map) def isMember = groupsResponse.body.groups.items.any { group -> group.name == groupName }

// Check if the user is a member of the specified group if (isMember) { def result = put("/rest/api/3/issue/${issueKey}") .header('Content-Type', 'application/json') .body([ fields: [ customfield_10002: [3] ] ]) .asString()

println("Organization field updated successfully.")

} else { println("Organization not found.") }