Bhavya-org / Scripts

0 stars 0 forks source link

Send email for ticket creation DNPTMC #43

Open sani-d opened 2 weeks ago

sani-d commented 2 weeks ago

def issueKey = issue.key def issueType = issue.fields.issuetype?.name // Added null check for issuetype def reporter = issue.fields.reporter?.accountId def tM_Version = issue.fields.customfield_11347?.toString() def rulename = issue.fields.customfield_11494?.value // Accessing value of custom field println("Issue Type: ${issueType}") println("Reporter: ${reporter}") println("tM_Version: ${tM_Version}") println("rulename: ${rulename}")

if ((issueType in ["TM alert", "TM Victim Alert"]) && reporter == "5b51cdecce51f259edf233a3" && !issue.fields.issuetype.subtask && tM_Version == "7" && (rulename == "DNPTMC" || rulename != "DNPTMC_V2")) { // Corrected condition checking println("Condition met") def resp = post("/rest/api/2/issue/${issueKey}/notify") .header("Content-Type", "application/json") .body([ subject: "${issue.fields.summary.find(/(company.{1,8})/)} Blocked Faster Payment DNP TMC", htmlBody: "${issue.fields.description}", to: [ users: [ [ accountId: '6386f36f2acfad92d7b3e2e4' ] ] ] ]) .asString()

println("Success")

} else { println("Condition not met") }

sani-d commented 2 weeks ago

def issueKey = issue.key

def resp = post("/rest/api/2/issue/${issueKey}/notify") .header("Content-Type", "application/json") .body([ subject: "Newly created ticket in Report a Tide Member of Staff (Tidean) Project", htmlBody: "You have received this e-mail as of the following ticket created: ${issue.fields.summary}", to: [ users: [ [ accountId: '5b02dbf8b2021155b92ea780' ], [ accountId: '5cb45aaaf2d6d50e543af8c7' ], [ accountId: '5cfe3acf5d548b0c51d6a560' ] ] ] ]) .asString()