Change the email language in the email pipeline from English to Chinese based on the selected language.
I have added a script before the alarm notification block and written the script below.
# Step 1: Get the locale (defaults to 'en' if not set)
locale = alarmEvent.get("locale") or "en"
# Step 2: Extract common alarm event values
displayPath = alarmEvent.get("displayPath", "")
eventTime = system.date.format(alarmEvent.get("eventTime"), "dd:MM:yyyy - HH:mm:ss")
priority = alarmEvent.get("priority", "")
setpoint = alarmEvent.get("SetpointA", "")
eventValue = alarmEvent.get("eventValue", "")
eventState = alarmEvent.get("eventState", "")
# Step 3: Create localized HTML email body
if locale == "zh":
emailBody = u"""
<html>
<body>
<h3>标题: COE 报警通知</h3>
<p>有一个报警已被触发,详情如下:</p>
<ul>
<li><strong>描述:</strong> {displayPath}</li>
<li><strong>事件时间:</strong> {eventTime}</li>
<li><strong>报警类型:</strong> {priority}</li>
<li><strong>设定值:</strong> {setpoint}</li>
<li><strong>事件值:</strong> {eventValue}</li>
<li><strong>状态变化:</strong> {eventState}</li>
</ul>
<p>请采取相应的措施。</p>
<a href="http://172.16.8.250:8088/data/perspective/client/Ignition_COE_Dev/AlarmPipelineack">点击此处确认报警</a>
<p>此致敬礼,<br>COE SCADA 系统</p>
</body>
</html>
""".format(
displayPath=displayPath,
eventTime=eventTime,
priority=priority,
setpoint=setpoint,
eventValue=eventValue,
eventState=eventState
)
else:
emailBody = """
<html>
<body>
<h3>Title: COE Alarm Notification</h3>
<p>An alarm has been triggered. Please find the details below:</p>
<ul>
<li><strong>Description:</strong> {displayPath}</li>
<li><strong>Event Time:</strong> {eventTime}</li>
<li><strong>Alarm Type:</strong> {priority}</li>
<li><strong>Setpoint Value:</strong> {setpoint}</li>
<li><strong>Event Value:</strong> {eventValue}</li>
<li><strong>Transitioned:</strong> {eventState}</li>
</ul>
<p>Please take action accordingly.</p>
<a href="http://172.16.8.250:8088/data/perspective/client/Ignition_COE_Dev/AlarmPipelineack">Click here for Alarm Ack</a>
<p>Best Regards,<br>COE SCADA System</p>
</body>
</html>
""".format(
displayPath=displayPath,
eventTime=eventTime,
priority=priority,
setpoint=setpoint,
eventValue=eventValue,
eventState=eventState
)
# Step 4: Store it in pipelineVars to be used in Email Notification block
pipelineVars["emailBody"] = emailBody
After that, I have added the notification pipeline. In the notification pipeline message section, I passed the parameter {emailBody}
Now, my email is sent, but it passes NULL data. If I remove the script and pass the message in HTML format, it sends the message accurately. However, we require the message in multiple languages. What can I do?