Select a file from the beginning of a flow

bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: Select a file from the beginning of a flow

Post 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
Benjamin
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: Select a file from the beginning of a flow

Post 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')!?
Benjamin
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Select a file from the beginning of a flow

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: Select a file from the beginning of a flow

Post 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.
Benjamin
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: Select a file from the beginning of a flow

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: Select a file from the beginning of a flow

Post 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 6505 times
The attachment Bildschirmfoto 2020-11-20 um 10.57.22.png is no longer available
Benjamin
Post Reply