Painless, watcher, alerts

Hi
I need to maintain key value pair for my output of transform block and send that to action block to send email to particular value its key. my sample code is below, my issue is in action block my payload is not getting transferred.

"transform": {
"script": {
"lang": "painless",
"source": """
def emailMap = [:];

  for (def hit : ctx.payload.hits.hits) {
    def jiraId = hit._source.jira_id;
    def approverEmail = hit._source.approver_email;
    
    if (jiraId && approverEmail) {
      emailMap[jiraId] = approverEmail;
    }
  }

  return emailMap;
"""

}
},
"actions": {
"send_emails": {
"foreach": "ctx.payload.entrySet()",
"email": {
"to": "{{ctx.payload.value}}", // Approver's email from the map
"subject": "Approval Required for Jira Issue {{ctx.payload.key}}",
"body": {
"text": "Please review and approve Jira Issue {{ctx.payload.key}}."
}
}
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.