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

Supratim
Contributor III

@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โ€}))

Thank you @Supratim for providing the string for file writer but this is failing as well.

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

Done, still not working for me.