Creating an Unique filename is a bit hard in Optio because the minimum time resolution is one second. And because some input can be faster than 1 second it can give rise to files being overwritten.

The way this solution works is by using the original input file, On Windows Servers this file is placed in the same folder and therefore needs to be unique. As it is almost impossible to print more than 256 documents in one second this example presumes the file name to be unique.

It is always possible to augment the TmpUniqueFilenameNoExt variable with extra's like Invoice number or Order number, but in a normal Windows setup you can be sure the given part of the filename is unique.

Put the following code in the Code Before of the document. You can use TmpUniqueFilenameNoExt as part of a file name like in the 'File name' property of a 'Save to disk' channel :

 = "Invoice_" & Layout.Header1.InvoiceNumber & "_" & TmpUniqueFilenameNoExt & ".pdf"

The filename will look like Invoice_12345_h0A_2321432234.pdf

Code Before of the document

// Start New code to save the file part 1
LET TmpIncomingSpool = PARAMETER("*",1)        // Get the name of the temp spool file

IF WHERE("~",TmpIncomingSpool) = 0 THEN        // check to see if you started from command line
   LET TmpIncomingSpool = "~0.tmp"              // if so, create an alternative name
END IF

// create a new, Unique file name Without extension or Path
LET TmpUniqueFilenameNoExt = TmpIncomingSpool[1,(WHERE("~",TmpIncomingSpool)+1)->(LENGTH(TmpIncomingSpool)-4)] & "_" & NOW()



Gesponsorde koppelingen