Skipping steps in ArcGIS Pro Tasks

371
4
11-06-2023 10:09 AM
samuel_e
New Contributor II

I am writing a task for users to run a custom python tool that adds developments such as an apartment complex or office park to a layer. For the first step, I want to let users zoom in on a municipality so it's easier to find the location (I think this is a pretty common first step). The first step is the Select Layer by Attributes tool, set to Auto Proceed. The second step is the Zoom to Selection command, set to Automatic and Hidden.

However, I want to allow users to skip this part of the task, if for example they are already looking at the right area or the development is in an unincorporated area that cannot be zoomed to. The problem is that I can make the Select step optional but not the hidden Zoom step, and then I get an error when the hidden step tries to run with no selection.

Is there any other way I can make step 2 optional? I am hoping I could either (1) only run Step 2 if Step 1 proceeds or (2) in Step 2, check if there is a selection and only run it if there is.

Tags (2)
4 Replies
PhilLarkin1
Occasional Contributor III

It would be awesome if Tasks provided more flow control. It is common that a unit of work requires some logical branching. Quite frequently I find myself wishing Tasks looked more like Microsoft's Power Automate Flow functionality. 

One way to make this more accessible and flexible would be to expose a Tasks class in arcpy. It would provide at least basic information about what step is being run.

0 Kudos
PhilLarkin1
Occasional Contributor III

You'll likely need to write some logic into your Step 1 script. You could do the Select by Attributes in the ToolValidation step and instruct them to skip Step 2 if appropriate. In this case an additional parameter that would hold a message sent to your users would be needed. 

0 Kudos
samuel_e
New Contributor II

Hi Phil, thanks for the suggestion. That could work. Sounds like it will have to be a visible step though, not hidden.

0 Kudos
PhilLarkin1
Occasional Contributor III

You are welcome. 

Logically speaking, as the Tasks framework is currently configured, it would be counter intuitive to have a hidden step that could also be skippable. The Tasks framework would need some sort of triggering logic, making the hidden step visible so a user could choose to skip it. You might consider submitting an Idea. There is lots of room for improvement in Tasks.  

0 Kudos