You will find that there's many ways to arrive at the ultimate final answer.
Don't worry about your initial post being too long or wordy, the more the better, especially when forum moderation might delay someone's reply hours or days. And often times something in the additional details either invalidates (or validates) possible responses.
Because you are picking into preprocessing scripts and there's not a lot of information about them, here's a couple things to keep in mind:
Nas will only run one preprocessing script - it will step through all the defined filters until the first match and then run that. There's been some back and forth about whether it's alphabetic or definition order in the cfg file that drives the evaluation order but ultimately I came to the conclusion that it was best for me to have only two preprocessing scripts: one that matched my production systems and one that matched my test/preproduction ones. I then was able to put all my matching logic in the script.
With everything in one file, any changes to that file become a big deal for testing. So, when I look at a request like your original one for my environment I ask the question of what will happen when I complete this work and another "entity" comes along? You typically have two options: Olaf's solution combines the data (entity name) with the logic which is an excellent process if the criteria is never going to change, the alternate solution in my suggestion is to separate the logic from the data so that the testing you do initially is valid whether there's 2 or 50 entities and when you need to add that 51st entity you really just need to test if the data change worked, not if any of the additional code broke any of the existing.
So, to update what I initially wrote to reflect your three entities, the guts of it would look like:
-- Build the event structure for testing
event = {}
event.user_tag_2 = "AHC"
event.message = "this is the message"
-- list is a table where the index is the value matched against your user tag 2 value and the value is whatever the append string is
list ={ ["AHC"] = " - BCA - Create ticket for AHC Field Services",
["AHN"] = " - BCA - Create ticket for AHN Field Services",
["AHF"] = " - BCA - Create ticket for AHF Field Services",} -- Note that the trailing , is perfectly valid - Lua allows that because sometimes lists like this are script generated and you don't have to handle the final line as a special case in generating it.
-- Always test values before you use them - saves headaches in the future
if ( event.user_tag_2 ~= nil ) then
-- Iterate over the table - k will hold the key value (AHC, AHN, AHF, etc.) and v will be the replacement string
for k, v in pairs(list)
do
if ( event.user_tag_2:find(k) ) then
print( "found " .. k )
event.message = event.message .. v
break
end
end
else
-- User tag 2 had no value
end
-- Display the result - probably "return event" in an actual script
print(event.message)