I was asked an interesting question the other day and thought to share this here:
"How to update or add the custom_x fields in an alarm using LUA OUTSIDE of pre-processing rules"
A normal pre-processing rule to operate on an alarm "graps" the alarm for you but in this case we are using the NimID to fetch the alarm from the NAS. Then we simply add the custom_x key and value and send the alarm back. The same alarm will now have your custom fields attached
a = alarm.get("RN45805640-28788")
a.custom_1 = "test"