Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to access file from file path

chanikya
Kilo Sage

Hi All,

one Team everyday they will place file in shared folder. so to get that file From run commander when I place "admin\Servicenow\majaordata\import\" , it will take me to Import folder , there are multiple files. Now I would like to access specific file from that list on everyday basis. this process should be done automatically by Scheduled job.

Could you please help me how to access file from Organisation internal shared folders file path 
\admin\Servicenow\majaordata\import\Masterdata_10Nov2025.csv



3 REPLIES 3

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @chanikya ,

Kindly refer to these links :

 

 

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Hi @SANDEEP DUTTA ,

First URL not able to access, could you please reshare it please.

can we use below code to Import file from internal UNC path (e.g. \\server\share\folder\data.json) ?

Scheduled Job :

  var midServer = "YOUR_MID_SERVER_NAME"; // name as shown in MID Server
  var filePath = "\\\\server\\share\\folder\\data.json"; 
  var dataSourceSysId = "YOUR_DATASOURCE_SYSID"; // sys_id of your Data Source

    var ecc = new GlideRecord('ecc_queue');
    ecc.initialize();
    ecc.agent = midServer;
    ecc.topic = 'FilePull';
    ecc.name = filePath;
    ecc.source = dataSourceSysId; // tag source for traceability
    ecc.queue = 'output';
    ecc.insert();

    gs.info("FilePull request sent to MID Server for file: " + filePath);