When I am calling integration hub policy in script include. I am facing issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2025 08:46 AM
Hi ServiceNow family,
I have created a integration hub retry policy. I want to call this retry policy in script include.
I have created script include and trying to call the integration retry policy I am facing below error in the logs -
Error in API request message : "sn_integrationhub" is not defined.
Script include code
var retry_functionality = Class.create();
retry_functionality.prototype = {
initialize: function() {
},
// Method that demonstrates using IntegrationHub retry policy
executeWithRetry: function() {
var retryPolicy = new sn_integrationhub.retry.RetryPolicy('EWM EPP Retry Policy'); // retry policy name
retryPolicy.maxAttempts = 3; // Number of retry attempts
// retryPolicy.retryInterval = 10; // Retry interval in seconds (optional)
// Execute the task with retry logic
retryPolicy.executeWithRetry(this._executeTask); // Pass a function to retry
},
// Task to be retried
_executeTask: function() {
try {
// Your API or other logic that may fail
gs.info("Executing task...");
// Simulate a failure (replace with actual API call or task)
var shouldFail = Math.random() > 0.5; // Random failure for demonstration
if (shouldFail) {
gs.error("Task failed!"); // Simulate task failure
throw new Error('Simulated task failure');
}
gs.info("Task completed successfully!");
} catch (error) {
// Handle errors here, they will be caught by the retry policy
gs.error("Error during task execution: " + error.message);
throw error; // Rethrow to trigger retry
}
},
type: 'retry_functionality'
};
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-01-2025 02:46 PM
The script is failing because 'sn_integrationhub.retry.RetryPolicy' isn't valid. Have you found some API documentation for this? Where has this come from?
You don't call a retry policy directly, it's referenced within a flow action