Is it possible to append additional text to a tags custom sms message inside of the pipeline using a script block?
The scenario is I would like to append a message to the text that says "reply STOP to unsubscribe" to any custom sms message that hits the alarm pipeline. If I cant do it this way I will have to write a script to roll thru every tag in the system. I can definitely do that but obviously the script block would be easier.
As you said, you can use a script block.
Alarm event are basically dictionaries. I don't remember the exact key, but it shouldn't be too hard to find.
Once found, you can modify it.
But the easiest way... would be to just add it to the notification block.
Any reason you can't do that ?
It was my understanding that if you used a custom message on the tag that the message portion in the sms notification block wouldnt be used.
I seem to remember being able to use the custom message in the notification block and adding stuff to it, but I could be mistaken, it's been long since I've done this.
the manual states that the custom message on the tag supersedes any custom messages on notification blocks.
Found it:
event['CustomSmsMessage']
So I guess something like
if event.get('CustomSmsMessage'):
event['CustomMessage'] += "\nReply STOP to unsubscribe"
I am able to get the custom message by using event['CustomSMSMessage'] but I cant update the message it doesnt seem unless I am not doing it properly.
logger = system.util.getLogger("myLogger")
sms = event['CustomSMSMessage']
newsms = sms + ' reply STOP to unsubscribe'
event['CustomSMSMessage'] = newsms
logger.info(sms)
logger.info(newsms)
Worked for me.
Note that you should probably be using a Set Property
Block instead of a script:
if (!isNull({CustomSmsMessage}),
{CustomSmsMessage} + '\n And More',
null
)
Tried your exact script (copy pasted):

Did you remember to save after editing ?
so I swapped to using the set property block and the sms messages still didnt have the updated message. I then put the script block after the set property block and logged the result of event['customsmsmessage'] and it shows the updated message before it hits the notification block. so the notification block itself isnt respecting the updated customsmsmessage. weird.
Try making the set property block Global
instead of Local
, or using event.global["CustomSMSMessage"]
or whatever the syntax is.
If the prop is set with a "set property block", then a script block logs the correct value, why would a notification block not get that same updated value ?
What does the global scope do to fix that ?
I tried using global but same result. it hits the logger and shows the appended text but the actual sms doesnt include the additional text
I forget the exact minutiae (alarming isn't my area) but if I remember correctly "local" means basically "within this one pipeline execution", where "global" can mean "at a higher level that underlying Java code retrieving properties will use".
I can't really explain why this isn't working. The notification block should just be retrieving the property off the alarm event:
String customMessage = notificationContext.getAlarmEvents().get(0).get(SmsProperties.CUSTOM_MESSAGE);