Send notification from workflow

umaaggarwal
Giga Guru
Giga Guru

I need to put incident to " in progress " status and send email to assignment group manager. if assignment group is empty, notification should go to assigned to 's primary group manager and if both are not there it should go to a static email.

 

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi Uma,

Create a workflow on incident table with condition state is New. Then add run script activity and in that you can look for current.assignment_group and current.assigned_to are having values or not. If yes, then assign as per your logic or else set the static mail.
You can set them into workflow scratchpad variable like below

workflow.scratchpad.Notify_to = value; //value should be the one that you set based on your logic.

Then add a notification activity and select advanced and in the script, use the earlier value that you got from run script into this like below

answer = workflow.scratchpad.Notify_to;

Mark the comment as a correct answer and helpful if it helps.

View solution in original post

3 REPLIES 3

Steven Parker
Giga Sage

There isn't an OOB workflow for Incident management I don't believe.  You would have to build one then trigger it based on a condition if you want to go that route.  Assignment lookup rules typically handle assignment groups for Incidents so in theory, there should always be an assignment group based on the Category/Subcategory chosen on the Incident.  Notifications are automatically sent to the Assignment group members on an Incident (manager should be one of those members).  

As for sending an email to a static email if assignment group is empty (if you still want to go that route), you would likely just build the notification and set the conditions necessary to trigger it.  You could take it a step further with a Business Rule and use the gs.eventQueue method to trigger it whenever you deem necessary and set the Incident status to "in progress".


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

AbhishekGardade
Giga Sage

Hello  Uma,

Why you want to trigger a notification from a workflow? You can trigger a notification from Event with the help of eventQueue().

1. Create an even in Event Registry on incident table. Lets say Event name: incident.notification

2. You need to create new business rule considering run conditions.

    Filter Condition: Incident State Changes to IN Progress

    Code for business rule.

        if(current.assignment_group !='' && current.assignment_group.manager != ''){
                         var mailToGroupManager = current.assignment_group.manager;
                         gs.eventQueue('incident.notification', current, mailToGroupManager, gs.getUserID()));
         }
         else if(current.assigned_to != ''){
                         var mailToAssignedTo = current.assigned_to;
                         gs.eventQueue('incident.notification', current, mailToAssignedTo, gs.getUserID());
         }
         else if(current.assigned_to == '' && current.assignment_group ==''){
                         var mailToStaticID = 'xyz@gmail.com';
                         gs.eventQueue('incident.notification', current, mailToStaticID, gs.getUserID());

         }

3. In Notification, You need to mark Event parm 1 contains recipient.  Check below image for understanding

find_real_file.png

4. For more detaila about eventQueue check below documention.

https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_automatingapps_madr...

 

Please mark answer as correct if you found it as helpful

Thanks,

Abhishek

 

Thank you,
Abhishek Gardade

asifnoor
Kilo Patron

Hi Uma,

Create a workflow on incident table with condition state is New. Then add run script activity and in that you can look for current.assignment_group and current.assigned_to are having values or not. If yes, then assign as per your logic or else set the static mail.
You can set them into workflow scratchpad variable like below

workflow.scratchpad.Notify_to = value; //value should be the one that you set based on your logic.

Then add a notification activity and select advanced and in the script, use the earlier value that you got from run script into this like below

answer = workflow.scratchpad.Notify_to;

Mark the comment as a correct answer and helpful if it helps.