javascriptjavarhinomirth

Mirth originalFilename rename


I have been trying to remove .dat from ${originalFilename} in destination when i tried to do this ${originalFilename}.txt it gave me like 1652807798759.dat.txt how can i get 1652807798759.txt only without .dat in it

I have tried to do this in Destination's Transformer but no luck

channelMap.put('OrigFilename', sourceMap.get('originalFilename'));

var outFile = channelMap.get('OrigFilename');
logger.info('outFile ' + outFile ); // i am getting outFile as null here
//outFile=outFile.replace('.dat','');

Solution

  • A simple replace should work:

    //test it with a static string first, in real code use sourceMap.get('originalFilename').toString();
    var outFile = '1652807798759.dat.txt' ; 
    outFile = outFile.replace(/\.dat/g, "");
    logger.info('outFile ' + outFile );