Disabling layer actions
I'm trying to create a custom layer action that will run a workflow that I've created that will zoom to the extent of a layer's features. I want to be able to disable or remove this layer action from the list of actions for all group layers in my map. Currently, the user will see an error as this isn't a valid context for that workflow to use.
Is there a solution that I can use so that I can a) set which layers have this layer action, or b) perform some logical check to determine whether the action should be disabled.
I already see that layer actions are dynamically populated on a per layer basis in some cases. For example, the Layer Style action is running the command "layers.ensure-can-set-symbol" prior to the "drawing.edit-symbol" command. I also see the "Hide when Disabled" setting in the Behavior section but have no idea what is setting the disabled property or how. I haven't found any good examples or documentation on how to control this behavior. Any ideas?
-
Hi Matthew,
The "Hide when Disabled" setting assesses whether a viewer command can be run and hides the Layer Action if this check fails. Unfortunately, in the case of workflows the workflow.run viewer command can execute perfectly fine even if the workflow itself fails, meaning Web won't hide the Layer Action if something inside the workflow is incompatible with the layer. To sum it up, Web successfully requesting a workflow to run doesn't necessarily mean the workflow will run successfully.
As for whether Layer Actions can be toggled on and off for individual layers, this is not possible yet as far as I know. There was talk of plans for implementing this, so hopefully we'll see this functionality come out soon.
I can think of a couple suggestions:
- Add a Try Catch activity or other error handling in the event that a user tries to run the workflow on a layer it isn't compatible with.
- Run the workflow from somewhere else in the app (for example, the "I want to..." menu) and pass it the necessary layer(s) instead of running it as a Layer Action.
- Add your voice to the article I linked above or post/upvote this functionality in our Ideas section to let the dev team know it's something you would like to see in Web in the future.
I hope that helps!
Alisa
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar