How to run Scheduled Data Import at random times of the day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 10:17 PM
Hi.
I want to import Data Source once a day.
Also, the time when importing once a day should be random.
I understand that I use Scheduled Data Import, but I don't know how to do it.
Help me!
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 12:00 AM
when you use scheduled import set and set any time or condition,
That will run the data source which will run the transform map connected to it.
Random timing is tricky part . you can use periodically every midnight or time when transactions are less or off business hours
Please mark my answer as correct if its helpful
Anshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 12:50 AM
Hi
in "Scheduled Import" records you have a checkbox field "Execute post-import script". After checking this you will be offered with a script field. In that field get the record of the same Scheduled Import and set a random time for the next schedule.
At the end the Scheduled Import modifies itself.
Kind regards
Maik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2022 12:16 AM
I'll just create a scheduled job to run at midnight to reset the time to run the scheduled data import.
Sample code:
var schDataImportSysId = '<sys_id of scheduled data import>'; // sys_id of scheduled data import to execute
var grSchDataImport = new GlideRecord('scheduled_data_import');
if (grSchDataImport.get(schDataImportSysId )) {
var gt = new GlideTime();
var hour = Math.floor(Math.random() * 24); // random hour
var minute = Math.floor(Math.random() * 60); // random minute
var second = Math.floor(Math.random() * 60); // random second
hour = ('00' + hour).slice(-2);
minute = ('00' + minute).slice(-2);
second = ('00' + second).slice(-2);
gt.setValue(hour + ':' + minute + ':' + second); // reset execution time
grSchDataImport.setValue('run_time', gt);
grSchDataImport.update();
}