I am needing DMT to run when a file is placed ins a specified folder. How do I do this?
You need to set up a âfile watcherâ service that will trigger when the file is placed in the directory. There are MANY programs and ways to do this. Google will be your best bet to start/learn about this process.
Another option is to have your Powershell script run on a timer ⌠like every 5 minutes ⌠and if there is nothing in that folder then just exit. Otherwise run DMT to process the file(s) that are in that directory.
Does the Source file have to be a specific name each time?
not required, but typically is when produced by some other program. It depends more on the method you choose to start DMT when the file arrives.
Another question, still on the main topic, but a bit off the original question. I am attempting to run a script that will used Sales Order Combined to update a few fields. I have the file in the correct location and the script doesnât have nay errors. However, after the PowerShell starts, noting in Epicor gets updated. Here is the script:
$DMTPath = âC:\Epicor*Location*\DMT.exeâ
$User = âuserâ
$Pass = âpassâ
$Source = âC:*Location*\DMT-Script Testing.csvâ
#Load Data
Start-Process -Wait $DMTPath -ArgumentList â-User=user -Pass=pass -noui -add -update -import"Sales Order Combined
â -update -Source $Source -configvalue=Test.sysconfig"
Can you guarantee that the CSV works when you use DMT interactively with those creds?
I wouldnât be surprised to see some goofy a$$ issues with how its reading âSales Order Combinedâ.
What I do is to use an object where I set the template name as a variable inside a variable like this and then I donât have to worry about apostrophes etc.
#Import Data From From BAQ -> CSV File -> Load in with DMT
$DMTPath = "C:\Epicor\Clients\EpicorLIVE\DMT.exe"
$User = "usr"
$Pass = "pw"
Write-Output "Importing Data via File $(get-date)"
$Source = "C:\Temp\VAL_Exports\SalesRegion.csv"
$Template = "Sales Region"
$DMTObj = '"{0}"' -f $Template
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import=$DMTObj -Source $Source -ConfigValue=Epicor10LIVE"
in your $Template variable, youâd set it as âSales Order Combinedâ. This is nice because it keeps 1 line of code where you change your template name.
Yes, the csv works when done manually and logged in with the user I am trying to pass on via script.
I will give this a shot!
This worked! Curious, can it be set to where no matter the name of the file, it processes it?
I suppose as long as the location is accessible, I havenât tried it though.
I was able to tweak your script and works very well! IS et this to run on a scheduled task and when the script is ran on the time schedule, and nothing is in the folder, then it just doesnât work. So, can the script be amended to see if anything is in the folder, if so run, if not, cancel.
Iâm trying to parse your words, but youâre asking if you can schedule the script to be run (yes) and append the script to first check the source folder for contents (yes)?
You gotta work on your google-fu my dude.
Schedule powershell script:
How to Schedule a PowerShell Script to Auto Run On a Windows Server (itechguides.com)
Check if a folder has contents:
Powershell test if folder empty - Stack Overflow
Sorry!
I already have the schedule set up. It is set to run every 5minutes. It was running and working as long as a file was in the folder. When there wasnât a file, it stopped. When it stopped, it wouldnât allow the schedule task to restart the 5 minute timer and run again. So I was thinking, run a script to check if a file is in the folder.
If there is a file in the folder, then run the script, else stop and run on te time schedule.
Thank you!
How do I make this script executable and have it run by the scheduler.
This is what I was looking for and I just posted looking for some help.
I have no powershell experience.
Thank You.
Did figure this out yet?
Iâm sure there are more elegant ways but I would set up the powershell script to run through a task in task scheduler.
Keep in mind this should likely be done on a server that is always on during the scheduled task time and not on someoneâs computer.