Preventing "resolve" if custom field undefined

We have a custom field “ServiceTag” and we want to make sure that technicians add a value to this field before resolving tickets.

I have already figured out how to write a scrip action to check if ServiceTag is undef On Resolve and if it is undefined, I just do a SetStatus(“open”) on the ticket. That works well enough. What I need now is:

  • How to add something to the transaction’s Results output at the top of the ticket display so that it is obvious that the ticket reverted to open (e.g. “TICKET CANNOT BE RESOLVED WITHOUT SERVICE TAG - REOPENED.”) Right now it reports that the ticket was resolved, but in the ticket display you can see that the Status is open, so I wanted to make that more intuitive.
  • How to add a Comment to the ticket from the scrip, or otherwise note in the transaction stream of the ticket that this event took place. Right now it records “The RT System itself - Status changed from ‘resolved’ to ‘open’” but I’d like an entry that explains why.

I’ve been reading the CustomScripAction wiki page and reading through source code of the various RT API files, but I am coming up empty. What’s the best way to accomplish these two things? (RT 3.8.7)