Skip to main content
Solved

Let end users decide whether to trigger a second workspace based on results form first workspace?


Hi, I’m looking for the best way to let end users decide whether to trigger a second workspace based on result (html data stream service) from first workspace. Is it possbile at all using eg. an automation app? If possible I also want to make use of the same parameters in both workspaces to make sure the geographic extent is the same.

My case is that workspace 1 runs some calculations to get costs. These costs need to be accepted by end user (Yes/No) before ruinning next workspace which produces som files. If possible I want to make use of the same parameters in both workspaces since it should make use om the same geographic extent.

Thanks for any ideas

12 replies

Userlevel 2
Badge +25

The two workspaces are separate flows.

The first flow is activated by a flow app, and creates some HTML output, that includes a link to a second flow app.

The second flow app starts the second workspace.

The user chooses whether to activate the link in the first output (as in “yes” to start it).

Parameters can be included in the link, if this is necessary.

Badge +5

Thanks @lifalin2016, sounds promising that you can include the parameters! Will give it a try. 

Userlevel 2
Badge +25

Alas, I may have been too hasty in promising parameters.

I was sure that it worked, but my simple workspace doesn’t adhere to my expectations :-(

I’ll do some tests.

But having the output of one flow trigger another is solid.

And you can define a flow (e.g. the secondary) to start immidiatedly without waiting for user input.

Userlevel 2
Badge +25

Alas, I may have been too hasty in promising parameters.

I was sure that it worked, but my simple workspace doesn’t adhere to my expectations :-(

I’ll do some tests.

But having the output of one flow trigger another is solid.

And you can define a flow (e.g. the secondary) to start immidiatedly without waiting for user input.

 

Unfortunately it doesn’t seem like flow apps take parameters directly. It would have been great if they did.

But you could store some sort of a random transaction number/GUID in a file or database table server-side, advise the user of this number, and have him enter it into the second flow app as an “acceptance token”, and use it to retrieve associated data.

Not great, but doable.

Userlevel 2
Badge +6

Hi @albjoh ,

Another option could be using a Flow app for the first workspace and using a webhook URL to run the second workspace. 

This article has a similar concept of a workspace app writing out an HTML file and there’s a button to run the workspace again with Data Download service and takes in the same parameter that was selected in the Flow app. 

https://support.safe.com/hc/en-us/articles/25407459193613-HTML-Page-with-Link-to-Download-Excel-File-FME-Flow-App

 

Hope this helps!

Kezia

 

Badge +5

Hi @keziaatsafe

Tried your solution but can’t seem to get my parameter to follow along into the data download phase where it is omitted in the url. The data streaming works but the ‘second run’ of the workspace ends in picture below. Can you think of any reason for this? I’m writing DWG rather than excel and the workspace is a bit more complex than your example, but can’t see why it should not work. 

  

Badge +5

@keziaatsafe Here is a more clear error message maybe:

 

Userlevel 1
Badge +9

Hi @albjoh

I suspect you need to encode the geometry parameter in the URL. You can encode it via our Python API https://docs.safe.com/fme/html/fmepython/api/fmeobjects/_utilities/fmeobjects.FMESession.encodeToFMEParsableText.html

 

I’ve created a workspace with a Python Script that you can use if that’s helpful. 
 

Badge +5

Thanks @siennaatsafe 

I’m not sure how to use provided Python API, sorry. However, I did manually encode the url into an identical string as the “Authorization with Query String” received when creating the webhook in Flow.

I tried to use “Authorization with Query String” as it is, for testing, just running it in a browser and it returns success as in below, but without any .zip for download:

 

But in the job-logs I get this message, which is why no .zip is provided I guess:

 

This is my url end up after encoding (excluding base url):

GeomParam=%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B12.11792%2C57.743391%5D%2C%5B12.11792%2C57.745041%5D%2C%5B12.120667%2C57.745041%5D%2C%5B12.120667%2C57.743391%5D%2C%5B12.11792%2C57.743391%5D%5D%5D%7D&opt_showresult=false&opt_servicemode=sync&token=e9248f481837818c9bbccf56a9523052934bcfbe

Userlevel 1
Badge +9

Hi @albjoh,


In your workspace, can you add a logger, to log the geometry parameter and run the job again?
 



What I’d like to see if how that parameter is being interpreted, I’m assuming it’s not being decoded by FME. So the Geometry replacer is trying to interpret:

%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B12.11792%2C57.743391%5D%2C%5B12.11792%2C57.745041%5D%2C%5B12.120667%2C57.745041%5D%2C%5B12.120667%2C57.743391%5D%2C%5B12.11792%2C57.743391%5D%5D%5D%7D

instead of:

{"type":"Polygon","coordinates":[[[12.11792,57.743391],[12.11792,57.745041],[12.120667,57.745041],[12.120667,57.743391],[12.11792,57.743391]]]}

If that is the case, you can use a TextDecoder to the parameter before the GeometryReplacer. Set the Encoding Type to URL Encoded, in the TextDecoder. Then, feed the decoded value to the GeometryReplacer.


 

Badge +5

Hi @siennaatsafe 

The workspace runs two times one via the app (datastreaming) and second via webhook (download). in the first run the logger gives expected geojson string:

Logger: Feature is:{"type":"Polygon","coordinates":[[[12.11792,57.743391],[12.11792,57.745041],[12.120667,57.745041],[12.120667,57.743391],[12.11792,57.743391]]]}

but the second time:

Logger_2 LOGGED Transformer Output Nuker (TeeFactory): Cloned 0 input feature(s) into 0 output feature(s)

Tried using a textdecoder to apply if not geojson format in GeomParam, but still got the same error. Also tried another approach using a parameter for users to supply a shp-file instead of drawing (geojson). Still got the same behaviour. 

Userlevel 1
Badge +9

Hi @albjoh

 

It’s likely easiest if we get on a call to discuss. Can you send me an email I’m at sienna.emery@safe.com then, I can send you a link to set up a call. Thanks!

Reply