- 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-02-2022 12:23 AM
then you can just run scheduled job before your scheduled import and get the date and update the file path
can you share how the file path looks like i.e. file name and will the date change based on today's date etc
Example: today the file name will be hello_2022_11_02 and tomorrow it will be hello_2022_11_03
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-04-2022 12:20 AM
I tried below script and I am getting the file name as ServiceNow_YYYY-MM-DD format. But How can I get the format in DD-MM-YYYY . Please guide
var grd = new GlideRecord("sys_data_source");
grd.addQuery('sys_id', 'datasource sysid');
grd.query();
if (grd.next()) {
var currentdate = new GlideDateTime().getDate();
grd.file_path = '/ServiceNow/ServiceNow_' + currentdate + '.csv';
grd.update();
}
- 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
‎04-25-2024 12:38 PM
I am sorry to bring this topic up.
I have slightly different question:
instead of single *.csv file per run, we use *.zip file which contains multiple *.csv.
How to get: which of unzipped filename is currently in the mapping transform process?
Is it possible?