- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 12:44 AM
Hi All,
I have to generate alert mails to members of Assignment group if Ctask has “assigned to” field is empty in 2 days after Change request is approved. Can anyone please let me know the possible ways.
Best Regards,
Pavan.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:25 AM
I believe I answered based on your original question you posted.
You can always enhance the script I shared based on your requirement.
I hope I have provided a thorough answer to your question. I'm confident that with your developer skills, you can take it further from here.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 06:33 AM
something like this will help you get started, please enhance it further from your side as per your requirement
-
Create a Scheduled Job:
- Navigate to System Definition > Scheduled Jobs.
- Click on New to create a new scheduled job.
- Fill in the necessary details:
- Name: Check Unassigned Ctasks
- Run: Daily (or as needed)
- Condition: Script
-
Add the Script:
- In the script section, add the following script to check for Ctasks with an empty "assigned to" field and send notifications:
(function() {
var gr = new GlideRecord('change_task');
gr.addEncodedQuery('assigned_toISEMPTY^approval=approved^sys_created_onRELATIVELT@dayofweek@ago@2');
gr.query();
while (gr.next()) {
var assignmentGroup = gr.assignment_group;
if (assignmentGroup) {
var members = new GlideRecord('sys_user_grmember');
members.addQuery('group', assignmentGroup);
members.query();
while (members.next()) {
gs.eventQueue('ctask.unassigned.alert', gr, members.user, gs.getUserID());
}
}
}
})();
-
Create a Notification:
- Navigate to System Notification > Email > Notifications.
- Click on New to create a new notification.
- Fill in the necessary details:
- Name: Unassigned Ctask Alert
- Table: Change Task [change_task]
- When to Send: Event is fired
- Event Name: ctask.unassigned.alert
-
Define the Notification Content:
- In the Who will receive section, add the recipients (e.g.,
Event Parm 1
for the user). - In the What it will contain section, define the email subject and message body. For example:
- Subject: Unassigned Change Task Alert
- Message:
<p>Dear ${recipient.name},</p> <p>The following Change Task is still unassigned:</p> <p>Task Number: ${number}</p> <p>Description: ${short_description}</p> <p>Please assign it as soon as possible.</p>
- In the Who will receive section, add the recipients (e.g.,
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2024 08:59 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2024 08:52 AM
Hi @Ankur Bawiskar,
Thank you for your response, but I noticed a slight deviation in the approach.
The current logic using in addEncodedQuery checks the approval of change tasks, but my requirement is slightly different. I need to check the approval status of the Change Record (change_request) itself. The goal is to identify if change tasks remain unassigned for 2 days even after the Change Record is approved. Could you please provide the logic for this.
Regards,
Pavan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2024 04:25 AM
I believe I answered based on your original question you posted.
You can always enhance the script I shared based on your requirement.
I hope I have provided a thorough answer to your question. I'm confident that with your developer skills, you can take it further from here.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader