Execute pre-import script - Data stream
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I need to pass a single input parameter to a Data Stream using the Pre-Import Script.
I've already defined this input parameter in the Data Stream configuration.
I've also set up a Scheduled Import and linked it to a Data Source.
In the Data Source, I selected the type as Data Stream, and below that, I can see the input parameter fields where I can provide values dynamically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi @sunilsargam ,
Use the Pre-Import Script in your Data Source to set Data Stream parameters dynamically before import runs.
Example:
(function(import_set_run, data_source) { var yesterday = new GlideDate(); yesterday.addDaysUTC(-1); data_source.setParameterValue('u_start_date', yesterday.getDisplayValue()); })(import_set_run, data_source);
✅ This overrides any static value in the Data Source form.
✅ Ideal for passing dynamic inputs like dates, sys_ids, or last import timestamps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Thank you @nityabans27 ,
I have added below script in scheduled import pre script section. this is not passing value to data stream. i have added logs to see if this is getting executed. no logs captured.
(function(import_set_run, data_source) {
var hoursAgo = 1;
var past = new GlideDateTime();
past.addSeconds(-hoursAgo * 60 * 60);
var isoDate = past.getValue();
var query = "$top=1000" + "&$select=ID" + "&$orderby=Id desc" + "&$filter=Modified ge '" + isoDate + "'";
var yesterday = new GlideDate();
yesterday.addDaysUTC(-1);
data_source.setParameterValue('query', query);
gs.info("log quiery predata" + query);
})(import_set_run, data_source);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Use Scheduled Data Import’s "Pre-Execution Script"
Go to your Scheduled Import record → scroll to the Pre-Execution Script field → place your code there:
This script does execute before a Data Stream call during scheduled imports.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
yes. i have done the same.