Bhavya-org / Scripts

0 stars 0 forks source link

Grant MS senior management access to privacy ticket ( request participants and Notify/email) #58

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 (requestType == "Fix an account problem") { def newRequestParticipants = [ [ "accountId": "63060b97189e0a3a4ff283dc" ], [ "accountId": "630a0d15ec02b5f28b63a024" ] ]

print "New Request Participants: ${newRequestParticipants}"

def updateResult = put('/rest/api/2/issue/' + issueKey)
    .header('Content-Type', 'application/json')
    .body([
        fields: [
            customfield_10127: newRequestParticipants // Use the correct custom field ID
        ]
    ])
    .asString()

print "Update Result: ${updateResult}"

def usersToNotify = newRequestParticipants.collect { participant ->
    [accountId: participant.accountId]
}

print "Users to Notify: ${usersToNotify}"

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: usersToNotify
        ]
    ])
    .asString()

print "Notification Result: ${notify}"

}