04-26-2022 02:43 PM
Hi Team,
While writing files via sftp, I’m unable to ingest Date.now() in the filename itself as seen in the snaps below:
(1) Successful execution [passing pipeline parameter and selecting the ‘=’ decorator
(2) Failed execution [NEITHER passing any parameter NOR selecting ‘=’ decorator]
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.
Thanks in advance for your help 🙂
Regards,
DT
Solved! Go to Solution.
04-29-2022 01:26 PM
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.
Can you please try the expression below first?
Date.now().toLocaleDateTimeString({"format":"yyyyMMddHHmmss"})
04-29-2022 11:58 AM
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.
04-29-2022 12:14 PM
Thank you @siwadon for your response but where did you find a colon ':'
in the file name?
04-29-2022 12:38 PM
Sorry for not being more specific.
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"}
.
04-27-2022 01:06 AM
Hey @darshthakkar,
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:
"sftp://localnetwork:22/usr/local/Enterprise/server/sharedcommon/incoming/SCM/Users/DT/inbound/ErrorLog.xlsx" + Date.now()
But I suppose you want the Date first, than the file extension so I would go with this:
"sftp://localnetwork:22/usr/local/Enterprise/server/sharedcommon/incoming/SCM/Users/DT/inbound/ErrorLog_" + Date.now() + ".xlsx"
Regards,
Bojan
04-27-2022 06:39 AM
Thanks @bojanvelevski for providing the actual string however it is failing as seen in the below snap: