- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:11 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:39 AM
Hi @mani55 ,
You can schedule the job to run monthly on the first day of each month, and include the relevant logic in the script.
use below code -
var currentMonth = new GlideDateTime().getMonth(); // Get the current month (1-12)
// Check if the current month is July (7) or November (11)
if (currentMonth == 7 || currentMonth == 11) {
//Write your code under it
}
It will allow you to run your job only on 1st day of July and November month only.
Hope this help you
Regards
Moin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:19 AM - edited â10-16-2024 02:19 AM
Hello @mani55
Yes you can, Create a Scheduled Job for Email Notification .
thank you, please if you find this helpful don't forget to click on the helpful button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:31 AM
How we can specified noveber1st week and july1st week
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:39 AM
Hi @mani55 ,
You can schedule the job to run monthly on the first day of each month, and include the relevant logic in the script.
use below code -
var currentMonth = new GlideDateTime().getMonth(); // Get the current month (1-12)
// Check if the current month is July (7) or November (11)
if (currentMonth == 7 || currentMonth == 11) {
//Write your code under it
}
It will allow you to run your job only on 1st day of July and November month only.
Hope this help you
Regards
Moin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â10-16-2024 02:34 AM
Hi @mani55 ,
To implement the notification scenario in ServiceNow, you can follow these steps:
1. Create a Notification
First, create a notification that will be sent to users with access rights.
- Navigate to System Notification > Email > Notifications.
- Click on New to create a new notification.
- Set the Name, e.g., "Access Rights Renewal Notification."
- Under the When to send tab:
- Set the Type to "Email."
- In the Send When section, select "Record inserted or updated."
- Under the Who will receive tab:
- Add a condition to specify the users with rights (e.g., based on a specific role or access group).
- In the What it will contain tab, compose the email message. Include instructions on how to respond to the Finance Team and state that failure to respond will result in deactivation of access rights.
2. Scheduled Job for Notifications
To send notifications automatically in the first week of July and November, create a scheduled job.
- Navigate to System Definition > Scheduled Jobs.
- Click on New.
- Set the Name (e.g., "Access Rights Notification Scheduler").
- In the Run section, set the job to run Monthly and Day to 1.
- Set the First run date to the first week of November 2024.
- In the Script section, use the following code to send notifications:
var currentMonth = new GlideDateTime().getMonth(); // Get the current month (0-11)
// Check if the current month is July (6) or November (10)
if (currentMonth == 7 || currentMonth == 11) {
var gr = new GlideRecord('sys_user'); // Adjust this to the correct user table if needed
gr.addQuery('your_condition_here'); // Replace with your condition to find users with rights
gr.query();
while (gr.next()) {
// Send notification for access rights renewal
gs.eventQueue('access_rights_renewal', gr, null, null);
}
}
3. Create an Event for Notifications
Create an event that will be triggered by the scheduled job to send out the notification.
- Navigate to System Policy > Events > Events.
- Click on New and create an event (e.g., "access_rights_renewal").
4. Response Handling
To manage user responses, create a separate table or use an existing one to log responses from users. You can also create a business rule to check for responses:
- Navigate to System Definition > Business Rules.
- Create a new business rule that triggers on the response record insert/update.
- In the business rule, check if a response was received. If not, schedule a job to deactivate access rights at the end of the month.
5. Deactivate Access Rights
To deactivate access rights, create a scheduled job or a business rule that checks if any user did not respond by the end of the month and then updates their access rights accordingly.
Hope this help to you.
Regards
Moin