Notification Messages

suvarna sonar2
Tera Contributor

We have custom field on group table u_manager_notification with choices None,P1, All, and P1 & P2. When this field update by P1 then record should be created in cmn_notif_message table. How to achieve this one?

1 ACCEPTED SOLUTION

@suvarna sonar2 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Nilesh Wahule
Tera Guru

Hi @suvarna sonar2 ,

You can use the After update business rule on the group table for same.

 

Condition: u_manager_notification IS P1 

 

Use this code then 

var grNotification = new GlideRecord('cmn_notif_message');
grNotification.initialize();
grNotification.<FIELD_NAME> = <DATA>;
grNotification.<FIELD_NAME> = <DATA>;
grNotification.insert();

 

Please note that you need to replace the FIELD_NAME and DATA with actual details.

 

---------------------------------------------------------------------------------------------------

Please mark my answer as helpful/correct if it resolves your query.

Thanks,
Nilesh Wahule

---------------------------------------------------------------------------------------------------

 

 

how to add group member of group in user field and also what to give in device

PritamG
Mega Guru

create a new business rule on the group table and set the condition to trigger when u_manager_notification changes to P1. then add script section follow condition

if(current.u_manager_notification == 'P1'){

var a  = new GlideRecord('cmn_a_message');

a.initialize();

a.field_name = 'value';

a.insert();

}

save and test.

Ankur Bawiskar
Tera Patron
Tera Patron

@suvarna sonar2 

something like this in after update BR

Condition: current.u_manager_notification Changes to P1

Script:

var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.getUniqueValue());
gr.query();
while (gr.next()) {
    var grNotification = new GlideRecord('cmn_notif_message');
    grNotification.initialize();
    grNotification.notification = 'notificationSysId'; // give the notification sysId here from table sysevent_email_action
    grNotification.user = gr.getValue('user');
    grNotification.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader