- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 05:50 AM
is there a better approach to considering performance by replacing scheduled jobs?
use case is for every minute need to check whether a new record was created or not!
Thanks,
Suresh.T
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:22 AM
Hi @Suresh Kumar Ta ,
Using scheduled jobs to check for new records every minute can be resource-intensive and may not be the most efficient way to achieve this. A more efficient approach would be to use event-driven or real-time mechanisms to detect and respond to the creation of new records. Here are some alternative options to consider:
-
Business Rules: You can create a Business Rule in ServiceNow that triggers when a new record is inserted. This rule can perform specific actions immediately upon record creation, eliminating the need for continuous polling.
-
Event Management: ServiceNow's Event Management module allows you to set up event rules that trigger actions based on specific conditions. You can configure it to respond to the creation of new records in real-time.
-
Scripted REST API: You can create a custom Scripted REST API in ServiceNow that listens for new record creation events. External systems or applications can then send POST requests to this API whenever a new record is created. This approach is more efficient and scalable than polling.
-
Integration Hub: If you're dealing with external systems, you can use Integration Hub in ServiceNow to set up bi-directional integrations. This allows you to push data into ServiceNow in real-time when new records are created externally.
-
Flow Designer: You can create a flow in ServiceNow's Flow Designer that triggers on record creation events and performs actions in response. Flow Designer provides a visual way to automate processes and respond to events.
-
Scheduled Imports: If you're monitoring data from an external source, consider using scheduled imports. ServiceNow can periodically pull data from external sources and create records based on that data.
-
Notifications: If you need to be alerted when new records are created, you can set up notifications in ServiceNow. Notifications can be sent via email, SMS, or through the ServiceNow notification system.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:22 AM
You can use an on insert business rule to generate an event or action
or a flow design that responds to an record insert trigger
constantly running a scheduled job every minute to check a record has been created sounds like a bad idea. Do you have more context? Maybe you are doing some automation to create the record and you want to know that it's been created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2023 06:22 AM
Hi @Suresh Kumar Ta ,
Using scheduled jobs to check for new records every minute can be resource-intensive and may not be the most efficient way to achieve this. A more efficient approach would be to use event-driven or real-time mechanisms to detect and respond to the creation of new records. Here are some alternative options to consider:
-
Business Rules: You can create a Business Rule in ServiceNow that triggers when a new record is inserted. This rule can perform specific actions immediately upon record creation, eliminating the need for continuous polling.
-
Event Management: ServiceNow's Event Management module allows you to set up event rules that trigger actions based on specific conditions. You can configure it to respond to the creation of new records in real-time.
-
Scripted REST API: You can create a custom Scripted REST API in ServiceNow that listens for new record creation events. External systems or applications can then send POST requests to this API whenever a new record is created. This approach is more efficient and scalable than polling.
-
Integration Hub: If you're dealing with external systems, you can use Integration Hub in ServiceNow to set up bi-directional integrations. This allows you to push data into ServiceNow in real-time when new records are created externally.
-
Flow Designer: You can create a flow in ServiceNow's Flow Designer that triggers on record creation events and performs actions in response. Flow Designer provides a visual way to automate processes and respond to events.
-
Scheduled Imports: If you're monitoring data from an external source, consider using scheduled imports. ServiceNow can periodically pull data from external sources and create records based on that data.
-
Notifications: If you need to be alerted when new records are created, you can set up notifications in ServiceNow. Notifications can be sent via email, SMS, or through the ServiceNow notification system.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:13 AM
Thanks Ratnakar for your response. My use case is as below.
I want to send a notification when a record is not created in a table for the last 5 mins without using schedule job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2023 01:56 AM
Hi @Suresh Kumar Ta ,
You can use gs.eventQueueScheduled
to implement a solution for your use case.
Here's an example of how you can use gs.eventQueueScheduled
for your use case:
(function () {
// Define the table and the condition to check
var tableName = 'your_table_name';
var condition = 'sys_created_on>=javascript:gs.minutesAgoStart(5)';
// Query the table to check if any records match the condition
var gr = new GlideRecord(tableName);
gr.addEncodedQuery(condition);
gr.query();
// If no records match the condition, send a notification
if (gr.getRowCount() === 0) {
// Create a GlideDateTime for scheduling the event
var scheduledTime = new GlideDateTime();
scheduledTime.addMinutes(5); // Schedule the event to run in 5 minutes
// Add your notification logic here, e.g., sending an email or creating an incident
// Schedule the event
gs.eventQueueScheduled('custom.notification.event', current,'','', scheduledTime);
}
})();
Also, refere documentation for more details : https://developer.servicenow.com/dev.do#!/reference/api/vancouver/server/no-namespace/c_GlideSystemS...
Thanks,
Ratnakar