Custom Javascript Functions Within a Workflow
Is there a way to use your own Javascript functions within a workflow?
I have tried including the function within Index.html of the viewer, and then referencing it from a ButtonBar submit event, and from an Evaluate Expression activity. In both cases, an error is raised: 'myFunctionName is not a function'.
The same error is also raised with built-in Javascript functions, such as encodeUriComponent(). Error: "Unable to run workflow '[object Object]'. [WF: expression evaluation error] The given expression could not be evaluated. "'http://www.jsoneditoronline.org/?url=' + encodeURIComponent('http://services.arcgis.com/BG6nSlhZSAWtExvp/arcgis/rest/services/QuakesCarib_3/FeatureServer/0/query?f=geojson&where=1=1')" encodeURIComponent is not a function". This Evaluate Expression activity should return:
At the moment, the only solution I can think of is to wrap the functions in a service and use Send Web Request to retrieve the result, but that seems like a lot of overhead when the workflow is running in the client anyways.
-
Hi Mel,
We intentionally block calls to custom functions from expressions as a security measure.
The way to execute custom JavaScript is via custom activities. A custom activity can wrap the call to your custom function, or you can implement all your custom code inside the activity.
In a few weeks we will be publishing the process for developing custom activities, but it isn’t quite ready for primetime yet.
I will look into how we can provide something like the encodeUriComponent() function. It will likely take the form of a built-in activity. Similar built-in objects like Math and JSON are also absent, but we provide roughly the same functionality via activities.
--Ryan
0 -
Hi Ryan.
That sounds like a perfect solution. Honestly, if you go down the path of recreating functions like encodeURIComponent, it's a never-ending uphill battle of recreating Javascript for every wanker like me who has a specific need. If custom activities look like what is running through my head, that's the superior solution.
Thanks,
Mel
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
2 kommentarer