cancel
Showing results for 
Search instead for 
Did you mean: 

Using Date.now() while exporting files

darshthakkar
Valued Contributor

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
image

(2) Failed execution [NEITHER passing any parameter NOR selecting ‘=’ decorator]
image

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

1 ACCEPTED SOLUTION

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"})

View solution in original post

21 REPLIES 21

First, check the spelling, I wrote the expression from the image you provided, so I may have missed something.

Also, I noticed that you’re using 2 different snaps in your samples above, so check if the Account is properly configured.

@bojanvelevski, I didn’t copy paste the link you provided as I have a different sftp location [which I can’t share unfortunately publicly]

Regarding account, yes, both the snaps have been mapped to the right account —> I double checked it.

Really appreciate your attention to detail, both the points were valid but it has already been taken care of!

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.

image

Try this and let me know.

This is not a concern as I’m able to write files at the same location without Date.now()

darshthakkar
Valued Contributor

@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.