The reason behind not selecting = decorator is - “I’m not passing any parameter to dynamically generate filename”
If the file name needs to be constant and it needs to be exported via sftp with Date.now(), what tweaks should I do? I’m pretty sure, snapLogic would be able to handle that and I might be doing something wrong here.
@darshthakkar Make expression enabled by clicking on the “=” on filename and can use below expression - “%s/%s%s.csv”.sprintf(“baseSFTPPath”,“constantFileName”,Date.now().toLocaleDateTimeString({“format”:“yyyyMMddHH:mm:ss”}))
Turn on the expressions support, and wrap the static part of the path in quotes. Than simply add the Date.now() function at the end. It will look something like this:
Check if the directories are already created and the path is valid. There’s an option within the File Writer snap that allows you to create the directories/path provided, if they’re not already present.
@darshthakkar Just to make sure you config correctly - 1. use wincsp/other tools to login the sftp server (please use same credential as used in snaplogic). And try to create a file there. If you can then it should work in snap as well.
2. Make sure you choose cloudplex/groundplex correctly.
3. And hope you validate this is sftp server not smb.
I think it is the problem with colon in the filename which is not a valid character in many file systems generally. You could try removing that from the expression.
I’m not sure about the expression you are using right now. But the output of Date.now() will contain colons in the time format, 2022-04-29T19:32:29.079 UTC.
Similarly, with the expression Date.now().toLocaleDateTimeString({"format":"yyyyMMddHH:mm:ss"}), you will still get the colons in the final output. If you are using this expression, you can try removing or replacing those colons with other characters. For example, {"format":"yyyyMMddHH-mm-ss"}.
@siwadon: Thanks for the clarification, I’ve replied to my previous comment so that you can check the screenshot of a successful run.
Date.now() works well if I’m passing a parameter for writing my files however if I provide a static name to a file (e.g. TestFile) and want to ingest Date.now(), it doesn’t work.
Again, Date.now() to a static file name would work if the files are written in snapLogic Manager however I faced the challenge while writing the files to a sftp.
Let me know if you need any further clarifications and I would be more than happy to provide you all the details.
Understood but I don’t think it’s the problem with the static or dynamic reference if you can write other files to the FTP server without any problems. The only thing I could think of is that the filename contains illegal characters.
@siwadon: Why would Date.now() work without any errors while passing a parameter and generating file names dynamically vs not working for a static file name? (both of them were written via a sftp itself)
Why would Date.now() work without any errors while passing a parameter and generating file names dynamically
I doubt that it would work without removing the colons because that’s the only difference. Can you verify if the file is written successfully? If that works, what is the filename you see on the server side?
Yes, the file was written successfully, in fact I generated ~5k html files on the sftp.
Moreover, the file name was unique, the file had 20+ columns but there was a column named ID (unique values) which was used as file name. The file name was sent as a parameter as you can see from the snap. i.e. _pipelineParameter