Bhavya-org / Scripts

0 stars 0 forks source link

Privacy Service Desk to Hristiyan Dimov (assignee / Notify) #59

Open Bhavya-ss opened 5 days ago

Bhavya-ss commented 5 days ago

def issueKey = issue.key def requestType = issue.fields.customfield_10010?.requestType?.name?.toString()

print "Issue Key: ${issueKey}" print "Request Type: ${requestType}"

if (["Fix an account problem", "Get IT Help", "Onboard new employees"].contains(requestType)) { 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}"

}