- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 07:50 PM
Hi, I have created a scheduled import to run the transform map via data source. How to fetch the dynamically based on latest updated file from the file path in SFTP folder in data source. If the file path is having multiple files, it has to pick the latest added/updated file. Please guide me how to achieve it
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-04-2022 12:31 AM
update as this
var grd = new GlideRecord("sys_data_source");
grd.addQuery('sys_id', 'datasource sysid');
grd.query();
if (grd.next()) {
var currentdate = new GlideDateTime().getDate().getByFormat('dd-MM-YYYY');
grd.file_path = '/ServiceNow/ServiceNow_' + currentdate + '.csv';
grd.update();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 12:52 AM
unfortunately you cannot achieve this using any OOB logic/configuration.
You need to determine just before your scheduled import in that SFTP file path which one is the latest and update the file path accordingly.
1) run scheduled job 30mins before your scheduled import and determine which file is latest and update the data source file path
2) when scheduled import runs it will fetch the file
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 04:00 AM
Could you please guide me with the steps for scheduled job how to determine latest file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 06:43 AM
will the complete file name change or just the date in file name will change?
based on that you can define the logic
check this
https://www.servicenow.com/community/developer-forum/retrieve-sftp-data/m-p/1631355/page/2
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2022 12:18 AM
Hi @Ankur Bawiskar , File name wont change, date in the file name changes.