How to trigger notification to more than one group through event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 05:28 AM
Hello Community,
Can anyone help us to trigger the notification more than one group members through the workflow event activity and it would be great if anyone provide code snippet or syntax for this logic.
Thanks,
Steve An
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 05:43 AM
Hi @Steveanner,
You need to get the all member of groups and return that variable in workflow event activity.
If it is email address, make sure to add it separated by comma.
Take a look at old thread: How to send notifications to multiple users in create event?
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 10:33 AM
Thanks for the response. It would be helpful if you could provide the syntax to retrieve multiple groups from workflow event activity parameter 1 to trigger notification.
Thanks,
Steve An
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 05:55 AM - edited 07-06-2023 05:58 AM
I would do the following:
- Create an event on the System Policy -> Registry table (sysevent_register)
- Create a notification in the system, System Notification -> Notifications, that is set to "Send When - Event is fired" and choose your newly created event.
- On the "Who Will Receive It" tab, you can add users/groups here, check the Event parm 1 contains recipient or Event parm 2 contains recipient boxes...click "Advanced View" under related links if you don't see all these fields. Obviously, the "What will it contain" tab is what you want in the email.
- Then in your workflow, use a Run Script and you would fire off the notification like the below. In this example, I am just using current and sending the requester and requested_for as the parm 1 and parm 2 fields. You can also send data or variables in those fields to use in the email, just don't check the "Event parm # contains recipient" box
gs.eventQueue("my_event_I_created", current, current.variables.requester, current.variables.requested_for);
That's just a quick example of how to do it. Few steps involved in the process.
Here are some more details from ServiceNow Docs:
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2023 10:31 AM - edited 07-06-2023 10:31 AM
Thanks for the response. Our case was different, and we needed to send to different groups based on the particular conditions. We are looking for a way to include more than one group in the parameter 1 in the workflow event activity to trigger
Thanks,
Steve An