web stats
filter by filename - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2014, 05:10 AM
gptomasini gptomasini is offline
Mirth Newb
 
Join Date: Nov 2013
Posts: 7
gptomasini is on a distinguished road
Default filter by filename

hi,

I'm not very good at JS but I know what I need.

I need to filter files coming from my "file"connector.

If filename "originalfilename" exists in processed folder (all files are moved here after process) then file should be discarded, otherwise it is accepted.

can someone help me with this.

thanks
gianý
Reply With Quote
  #2  
Old 05-19-2014, 05:45 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

Hi,

try something like this in your filter.
please keep in mind that you need to have the full unc path to the file (code example below looks at the C drive where Mirth is installed).


Code:
var continue = false;
var f = new java.io.File("C:\\temp\\testFile.hl7");

if(f.exists() && !f.isDirectory()) { 
	logger.error("file is there");
        continue = false;
        //do whatever you want.
} else {
	logger.error("file is not present");
        continue = true;

}

return continue;

Last edited by StefanScholte; 05-19-2014 at 05:48 AM.
Reply With Quote
  #3  
Old 05-20-2014, 03:16 AM
gptomasini gptomasini is offline
Mirth Newb
 
Join Date: Nov 2013
Posts: 7
gptomasini is on a distinguished road
Default

Hi Stefan,
thanks for answering to my message. You really helped me in finding the right solution.
follows what i put in my filter and it works.!!!
thanks agian for your great support....but now I'm into something else another channel and I think i will have to contact you again for more help !!!
thanks

var fileA = channelMap.get('originalFilename');
var f = new java.io.File('D:/processed/'+fileA);

if(f.exists()) {
logger.error("file was already processed, this file was discarded");
return false;
//do whatever you want.
} else {
logger.error("file has been sent to destinations");
return true;

}
Reply With Quote
Reply

Tags
file exists, filter

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation