Page 2 of 2

Re: Select a file from the beginning of a flow

Posted: Thu Nov 19, 2020 9:09 am
by bkromer
jan_suhr wrote: Mon Nov 16, 2020 9:59 am You renamed the payload file and also changed the extension. The filename before the extension must be alike but different extensions. The filetype you want to embed as an opaque datatype i specified in the properties.

You you need two files as this: myfilename.pdf and myfilename.json
okay thanks. Now i got the pdf with the json attached to it but it seems like i cannot enter the opaque metadata.
Image

Re: Select a file from the beginning of a flow

Posted: Fri Nov 20, 2020 9:07 am
by bkromer
Is there a way to "File.read()" a File thats not in the actual Job-Folder of the Script? How can I refer to such a file? For Example the JSON file is in Folder 11 how can I read it by refering to it like File.read('Ordner 11/filename.json')!?

Re: Select a file from the beginning of a flow

Posted: Fri Nov 20, 2020 9:20 am
by jan_suhr
Opaque datasets is just a container that keeps the dataset file as an attachment to the job file. You can just see that it is there together with the job file. To be able to get to it you must use the Export Metadata to get to it. It will then go out through the Log Connection.

Re: Select a file from the beginning of a flow

Posted: Fri Nov 20, 2020 9:41 am
by bkromer
So you mean the Flow Element "Export Metadata"? So I cant use job.getVariableAsString( '[Metadata.Rational:Path="Opaque"] ')?

In My Flow I get a JSON from a WebHook within the JSON is the name of the PDF-File I want to print via "Flux Server API" and various information for the job.

So I need the PDF to upload it to the API and I need the json to send it to the API. When I put the whole json in privateData it doesnt work, I am not able to parse or read it as json anymore.

Re: Select a file from the beginning of a flow

Posted: Fri Nov 20, 2020 9:45 am
by jan_suhr
As it is at the moment Switch can't read JSON as metadata, metadata must be XML. You could write a script that reads the JSON and get the variable saved as Private data to your PDF.

Re: Select a file from the beginning of a flow

Posted: Fri Nov 20, 2020 10:59 am
by bkromer
Okay this worked for me now:

Code: Select all

var dataset = job.getDataset( "OpaqueJson"  );
var jsonFilePath = dataset.getPath();
var jsonFileObj = File.read( jsonFilePath ,'utf-8'); 
var orderJson = JSON.parse( jsonFileObj );
Bildschirmfoto 2020-11-20 um 10.57.22.png
Bildschirmfoto 2020-11-20 um 10.57.22.png (83.66 KiB) Viewed 6587 times
The attachment Bildschirmfoto 2020-11-20 um 10.57.22.png is no longer available