Bell Notification not routing properly

Servicenow34
Tera Guru

Requirement : When new record inserted to live_notification table and user is not empty one bell notification should created and route to the table record mentioned in the live_notification record.

 

Issue : 

I have created provider notification and its related records (ie content , action and link actions to record) however it is roting to the live_notification table record instead of the expected one.

I have tried by adding the log in action script however system is skipping the action.

Servicenow34_0-1776364808506.pngServicenow34_1-1776364848519.png

 

Servicenow34_2-1776364896689.pngServicenow34_3-1776364992547.png

 

 

1 ACCEPTED SOLUTION

lauri457
Tera Sage

Are you possibly trying to create a notification based on mentions?

 

You can't use the record change trigger as it will have a fixed table. What you want is an async on insert business rule on live_notification. Then you want to queue an event using the record referred on the notification record by querying it with gliderecord.

(function executeRule(current, previous /*null when async*/) {
	var mentiodOnGr = new GlideRecord(current.getValue("table"));
	if (mentiodOnGr.get(current.getValue("document"))) {
		gs.eventQueue("mention.task", mentiodOnGr, current.getValue("user"), current.getValue("field_name"));
	}
})(current, previous);

Change the trigger to event and remember to remove the table unless you want it to work for a single table of course. Remember to tick that recipient (sys_user) is in the event parm1 if using above.

View solution in original post

9 REPLIES 9

AlpUtkuM
Mega Sage

You could use flow designer to send email instead of creating notification.

 

Condition to run the flow : Record insterted on live_notification table where user is not empty

 

Then you could use email action on flow to send email notification

lauri457
Tera Sage

Are you possibly trying to create a notification based on mentions?

 

You can't use the record change trigger as it will have a fixed table. What you want is an async on insert business rule on live_notification. Then you want to queue an event using the record referred on the notification record by querying it with gliderecord.

(function executeRule(current, previous /*null when async*/) {
	var mentiodOnGr = new GlideRecord(current.getValue("table"));
	if (mentiodOnGr.get(current.getValue("document"))) {
		gs.eventQueue("mention.task", mentiodOnGr, current.getValue("user"), current.getValue("field_name"));
	}
})(current, previous);

Change the trigger to event and remember to remove the table unless you want it to work for a single table of course. Remember to tick that recipient (sys_user) is in the event parm1 if using above.

Hello @lauri457 , Thank you for your response.

I was checking your another post. (https://www.servicenow.com/community/developer-forum/modify-provider-notification-before-sending/m-p...

 

are you able to route to your target record instead of live_notification ?

Please let me know.

 

If you use an event to trigger the notification then the target record will be the gliderecord that is given as the second argument to gs.eventQueue. As long as you leave the table on the notification empty then it will work on any table.

That's why you have to query the record based on the document id and table fields and NOT use current.