Question

Help creating dynamic input user parameter drop down list, and then the dynamic output file attributes

  • 28 August 2020
  • 3 replies
  • 102 views

Badge +7

I have recently installed FME Server I have been working through some tutorials, and reviewing the examples installed on the server, to see if I can automate some things I currently do manually. 

 

The first one I am working through is actually based on one of the tutorials in the server training material (Ex 3.3 here). 

 

What I am hoping to achieve is that we can have an FME Server tool that the user can access, select from a list of arcgis online feature layers (things like watermains, property boundaries, etc), then the user can draw a polygon on a map to define the extents, and FME will output this data to the user, including ALL attributes within the selected Feature Layer.

 

Currently I have the attached template, it kind of works, as in it successfully exports the correct spatial data, but for the life of me I cannot work out how to get the attribute data of the selected feature layer to be export to the XLS output file.

 

As previously mentioned, the second thing I am trying to work out is whether or not I can create a user parameter to provide a list of available ArcGIS Online Feature Layers as the input data to be filtered on. I wouldn't know where to start with that one.

 

Any pointers would be greatly appreciated.

 

2020-08-28 12_07_45-NONE to XLSXW (C__Users_Ben_Desktop_Clip AGOL Data.fmw) - FME Workbench 2020.0


3 replies

Userlevel 4

Try creating a new connection diretly between the <Schema> output port of the FeatureWriter and the Excel output feature type. Also, open the output feature type attributes and make sure to tick the box "Dynamic schema defintion". This will allow the Excel writer to use the schema defintion from the input features.

 For the second question, unfortunately there is no easy way to create dynamic parameters in FME. The parameter values must be known before the workspace is published.

To make those parameters (partially) dynamic?

One of my colleagues asked me to build some functionality to add extra items in a pulldown parameter.

I was used to do things like this in Excel: Userform in VBA and fill the pulldown on demand pretty easy.

In FME it took me queued some time to figure out this one. But the solution was surprisingly simple:

When I discovered that *.fmw are xml’s, I started to redefine the problem. After a successful test on reading and writing fmw-files as text files with an alias (*.fmw) extension, I only had to update the file on the server. And that’s easily done with a HTTPCaller. All though its partially dynamic (user has to update workbench in advance with a separate service), it gave my colleagues the opportunity to update the pulldown list without me updating the workbench for them.

I hope this idea will help you too. Good luck.Making parameters partial dynamic

Another (probably more useful) method I’d like to share:

In this method there are two Workbenches needed. 

concept dynamic pulldownThe first Workbench gathers the choice options found in the by the user uploaded source file and will create a HTML where these options are summarized in choice lists presented to the user as questions with a dropdown menu. In the screenshot below the needed HTML. (Tip: by using Data Streaming on FME Server the HTML will open in same browser).

HTML codeI used a pythoncaller to build the choice lists. And I included a parameter with the location of the source file, to tell the second Workbench where to find it. One important thing to know is that this file location parameter (string) can’t be added directly in the API’s URL, therefore it must be encoded to BASE64

 

After the user submits his/her choices, the HTML is using a PHP File (to be stored on your web server) that will send a request to the API of the second Workbench. In the screenshot below the code I used. The parameters that are part of the second workbench are part of the API URL, so these have to be filled in. I chose a method in which the individual parts are concatenated in a join action.

PHP to approach the APIIn the second workbench the file location parameter has to be decoded to UTF-8 and then the source file can be read again. And after that you can do whatever you want with the gathered values in parameters.

Reply