Bhavya-org / Scripts

0 stars 0 forks source link

Personal Data Breach ticket assign to Hristiyan Dimov ( assignee / notify for issuetype condition) #60

Open Bhavya-ss opened 5 days ago

Bhavya-ss commented 5 days ago

def issueKey = issue.key def issueType = issue.fields.issuetype?.name

print "Issue Key: ${issueKey}" print "Issue Type: ${issueType}"

if (issueType == "Task") { def newAssigneeAccountId = '6305b88c958ffd78c6e0e59e' // Use the account ID of the new assignee

def updateResult = put('/rest/api/3/issue/' + issueKey + '/assignee')
    .header('Content-Type', 'application/json')
    .body([
        accountId: newAssigneeAccountId
    ])
    .asString()

print "Update Result: ${updateResult}"

def notify = post("/rest/api/2/issue/${issueKey}/notify")
    .header("Content-Type", "application/json")
    .body([
        subject: "Issue ${issueKey} was just created",
        htmlBody: """Please copy and paste ${issueKey}""",
        to: [
            users: [
                [
                    accountId: "63060b97189e0a3a4ff283dc"
                ]
            ]
        ]
    ])
    .asString()

print "Notification Result: ${notify}"

}