- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2020 08:04 AM
I need to import a csv file from MID Server daily... Daily once the 3rd party will place a csv file in the MID Server...when ever they place I need to place that file in our MID Server...
Can anyone help me with this? I referred previous community questions but I didn't get complete clarity...so please help me to understand clearly
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2020 08:11 PM
Please find responses below
Question 1: Regarding First Script [Background Script ]
Should I run this in our instance is enough ? (or) should I login to Server in which MID Server is located and there I need to login to my developer instance and run?
- you should run this from your instance which is configured with the mid server
Question 2 : Regarding Business rule..
By this business rule..where my CSV file will get stored? It needs to attach to a import table in our instance
- you can attach it to the data source which you require to be transformed
- remember you need to trigger the transform as well once file gets attached to data source
Question 3 : This Process needs to run daily at certain time..
- create a schedule job which runs daily and uses the script shared above
Regards
Ankur
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-07-2020 08:15 AM
You will require mid server script include for this which requires scripting knowledge of java packages call and javascript combination.
you will require daily schedule job to trigger the mid server script include at particular time.
refer these links for help
File Import (CSV / XLS) file from Mid Server location
CSV file from MIDserver to ServiceNow instance
How to import excel file from Mid Server to import set table in service now.
Regards
Ankur
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-07-2020 09:43 AM
HI
From this scenario I want to proceed with Workaround3 from the below mentioned hi ticket...but I didn't understand how to use that script.. can you please explain how to use it and let me know whether that Workaround 3 will satisfy my requirement or not..
https://hi.service-now.com/kb_view.do?sysparm_article=KB0817437
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2020 09:53 PM
If you want to take workaround 3 then
You will have to use background script to use this script
1) Ensure you give valid file path and file name
a) the file here is example.csv present in folder Desktop
2) Ensure you give valid mid server name which is up and running
This will give you the base64encoded data of that file
var probe = SncProbe.get("Command");
probe.setName("cd /Users/me/Desktop && cat example.csv | base64");
probe.create("<MID Server Name>"); // give mid server name here which is up and running
Then write after Insert Business rule on ecc_queue table
Condition: current.queue == "input" && current.state == "ready"
Script:
1) get base64encoded data and then use soap attachment creator
2) please check the ecc_queue payload where the base64encoded data is present and accordingly parse the XML and use
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var payload = current.payload;
// please check which xml tag in the payload contains the base64encoded data and parse the XML and then use in the payload line of code below
var base64encodedData = ''; // after parsing this will contain the base64encoded data
var s = new sn_ws.SOAPMessageV2('Attachment Creator', 'insert');
s.setStringParameter('agent','AttachmentCreator');
s.setStringParameter('name','example.csv:text/csv');
s.setStringParameter('source','incident:407b07654f562200fc11fa218110c75e');
s.setStringParameter('payload',base64encodedData);
s.setStringParameter('topic','AttachmentCreator');
var response = s.execute();
})(current, previous);
Regards
Ankur
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-08-2020 08:26 AM
Thank You so much
Sorry to ask you again...I had some small queries can you please clarify me...
Question 1: Regarding First Script [Background Script ]
Should I run this in our instance is enough ? (or) should I login to Server in which MID Server is located and there I need to login to my developer instance and run?
Question 2 : Regarding Business rule..
By this business rule..where my CSV file will get stored? It needs to attach to a import table in our instance
Question 3 : This Process needs to run daily at certain time..
Please help me