Select a file from the beginning of a flow

User avatar
bkromer
Member
Posts: 71
Joined: Thu Jul 11, 2019 10:41 am
Location: Germany

Re: Select a file from the beginning of a flow

Post by bkromer » Thu Nov 19, 2020 9:09 am

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 Kromer

User avatar
bkromer
Member
Posts: 71
Joined: Thu Jul 11, 2019 10:41 am
Location: Germany

Re: Select a file from the beginning of a flow

Post by bkromer » Fri Nov 20, 2020 9:07 am

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 Kromer

jan_suhr
Advanced member
Posts: 379
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 » Fri Nov 20, 2020 9:20 am

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

User avatar
bkromer
Member
Posts: 71
Joined: Thu Jul 11, 2019 10:41 am
Location: Germany

Re: Select a file from the beginning of a flow

Post by bkromer » Fri Nov 20, 2020 9:41 am

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 Kromer

jan_suhr
Advanced member
Posts: 379
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 » Fri Nov 20, 2020 9:45 am

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

User avatar
bkromer
Member
Posts: 71
Joined: Thu Jul 11, 2019 10:41 am
Location: Germany

Re: Select a file from the beginning of a flow

Post by bkromer » Fri Nov 20, 2020 10:59 am

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

Post Reply