What exactly is not working? What are the error messages? Do you have a separate table that you want to insert all your alarms (along with the user inputted reasons) into? It will be easier to help with some extra context about your situation and goals.
Also please check out this How to post code on the forum post.
I don't know where you got your code from, but it was not meant to work without any modification. You have lines like this:
If your code code came from an LLM AI (like ChatGPT), I'd advise you to refrain from using AI for Ignition scripting. Ignition is simply to niche, and AI (today) does not have adequate knowledge on it. It will quietly and confidently just give you bad or bogus code, (especially since so much of Ignition scripting is dependent on the context that it is in). Inductive Automation does a good job with the manual; don't hesitate to read it.