Script in Workflow Notification

stevenm
Kilo Guru

My users would like an email notification come out of a workflow.   That's all fine and dandy.   However, they would like the body of the email to be based on some of the values entered on the service request.   For instance if a field says approver they would like the email text to reflect approver otherwise have it reflect non-approver.   Will mail_script work within a Workflow Notification?   I'm not getting any output from the if statement below.

Capture.JPG

1 ACCEPTED SOLUTION

stevenm
Kilo Guru

This is really old and I don't recall why my question.  Thanks for replying.  I guess I better mark it closed.

View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

Hi Steve,



I recommend using the event triggered method of sending notifications from workflow. It has several advantages:


  • Centralized management of all notifications
  • Easy of updates on notifications (update the notification instead of checking out and making revisions to the entire workflow)
  • Enables internationalization (multi-lingual)
  • and as you seem to have discovered, scripting capaibilties


I haven't verified that last one. You may get away with the modern format of ${mail_script:mail_script_name}



Scripting for Email Notifications - ServiceNow Wiki


Email Notifications - ServiceNow Wiki


http://wiki.servicenow.com/index.php?title=Events_and_Email_Notification


I'd like to offer an alternative point of view on this one. We debated this for a while and decided to maintain notifications shared across request management for all items in the notifications table in order to take advantage of your first point, centralized management. Some of our users, however, feel (sometimes legitimately) that their items merit non-standard notifications. In my opinion, it's a pain to have these non-standard, one-off notifications intermingled with all of the other notifications on the shared RM tables in the shared notifications table. When I want a quick look into what we're sending out for all records in sc_req_item, I have to filter through x number of non-standard notifications in order to get an answer. It's nice to be able to quickly look and see what's standard, and then look to a particular workflow when I want to know what's going out for that item that isn't standard.

I think there's a degree of preference that comes into play with this, and the important thing is to adhere to a standard regardless of the route you pursue.

All of this said, Chuck makes fair points with both easy updates and internationalization. As to scripting, more complex options may prove challenging, but Chani's syntax does work for variables. I have not gotten the modern format for mail scripts to work.

stevenm
Kilo Guru

Does this mean I can't do it the way that I'm attempting?   It won't work?


Hi Steve,



As noted, I haven't tested mail scripts in workflow notification activities. I generally don't use them. While they are simpler, they are less flexible and more difficult to maintain (IMHO.)



Use the "Generate event" activity and you can create a notification under System Notification> Email> Notification with the rest of them that responds to an event.