The CreatorCon Call for Content is officially open! Get started here.

Trigger notification when state & latest comment/worknote contains "additional information required"

Dhanunjay Kumar
Giga Contributor

Hi Experts,

 

We have a requirement to trigger notification when state changed and latest comment/worknotes contains "additional information required".

Please help me with the solution.

 

Thanks, Jay

4 REPLIES 4

Hristo Ivanov
Kilo Sage
Kilo Sage

Hey Jay, 

 

Navigate to Email > Notifications, create new, select table and if it will be triggered on insert or update and then click on advanced view, in the script section you can try the following 

if (current.state.changes() && (
        ('' + current.comments).toLowerCase().indexOf('additional information required') > -1 ||
        ('' + current.work_notes).toLowerCase().indexOf('additional information required') > -1
    )) {
    answer = true;   // send the notification
} else {
    answer = false;  // do nothing
}

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Dhanunjay Kumar 

 

OOTB this way:

DrAtulGLNG_0-1748963343585.png

 

 

but to fulfil your requirement , you need to a script.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Roshnee Dash
Tera Guru
Tera Guru

 

  • Create a Business Rule:

    • Navigate to System Definition > Business Rules.

    • Click New to create a new rule.

    • Set the table to the desired record type (e.g., Incident, Task).

    • Choose Before and Update as execution types.

  • Add Conditions:

    • Ensure the Business Rule runs when the state,work note and Additional comments  field changes.

    • Use a condition like:

current.state.changes() && (current.comments.indexOf("additional information required") != -1 || current.work_notes.indexOf("additional information required") != -1)
  •  This checks if the state has changed and if the latest comments or work notes contain the specific phrase.
  • Trigger Notification:

    • Under Actions, create a new Email Notification.

    • Configure the recipient, subject, and message body to include relevant details.

    • Set the notification condition to trigger when the Business Rule runs by calling event from the business rule.

  • Alternate Approach: Scripted Action

    If you need more control, create a Script Action inside the Business Rule:

if (current.state.changes()) {
    var latestComment = current.comments || "";
    var latestWorkNotes = current.work_notes || "";

    if (latestComment.includes("additional information required") || latestWorkNotes.includes("additional information required")) {
        gs.eventQueue("notify_additional_info", current, current.sys_id, current.sys_updated_by);
    }
}
  • Then, set up an Event (notify_additional_info) to trigger an email notification.

 

 

Your feedback makes the community stronger! If you found this helpful, marking it as the correct answer helps others.
Stay awesome,
Roshnee Dash

Hi @Dhanunjay Kumar 
If you found my response helpful, please mark it as correct and close the thread so others can benefit from it too.

Your feedback makes the community stronger! If you found this helpful, marking it as the correct answer helps others.
Stay awesome,
Roshnee Dash