Select to view content in your preferred language

Scripting Tools: Setting parameters so that one or both must be answered

619
4
Jump to solution
12-09-2021 02:17 PM
AlfredBaldenweck
MVP Regular Contributor

I'm trying out a script that does two related functions.

I have it set up so that either function can run by itself, or you can run both simultaneously.

My parameters are as follows

  1. Input GDB
  2. Run Function A? (toggle)
  3. Output Location (Function A)
  4. Output Location (Function B, essentially acts as its toggle)

Is there a way to make it so that either B or D, or both of them together, must be answered? 

Basically I'm trying to avoid the users running the tool in such a way that neither function runs.

Similarly, is it possible to make Parameters have conditional visibility? Like, C only shows up if B is answered or toggled.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
LongDinh
Frequent Contributor

Hi Alfred,

What you are after is Script Tool Paramter Behaviour. You can set the Parameter[i].enabled = True/False to enable disable a parameter. You can apply a condition on Parameter B's values to dynamically enable/disable Parameters C/D.

 

The logic would be something like the below:

Parameter B should be a MultiValue list with your selectable (filter) options: Function A, Function B

Parameter C has a dependency on Parameter B and is enabled when Parameter B has Function A in its list of values. 

Similarly, Parameter D has a dependency on Parameter B and is enabled when Parameter B has Function B in its list of values.

If both Function A and Function B are selected in Parameter B, both Parameter C and D will be selectable.

Hope this helps!

View solution in original post

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

I use custom toolboxes... easier to see what is going on and minimizes code validation.

multivalue_parameters.png

But I am sure you can emulate if you have to use the other toolbox form


... sort of retired...
0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Yes, I'm using that, too.

I'm looking to make it so either Parameter B or Parameter D must be answered.
It doesn't matter which one of them is answered.

Parameter ARequired

Parameter B (optional)

OR

Parameter D (optional)

Required
Parameter CRequired
0 Kudos
LongDinh
Frequent Contributor

Hi Alfred,

What you are after is Script Tool Paramter Behaviour. You can set the Parameter[i].enabled = True/False to enable disable a parameter. You can apply a condition on Parameter B's values to dynamically enable/disable Parameters C/D.

 

The logic would be something like the below:

Parameter B should be a MultiValue list with your selectable (filter) options: Function A, Function B

Parameter C has a dependency on Parameter B and is enabled when Parameter B has Function A in its list of values. 

Similarly, Parameter D has a dependency on Parameter B and is enabled when Parameter B has Function B in its list of values.

If both Function A and Function B are selected in Parameter B, both Parameter C and D will be selectable.

Hope this helps!

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

This looks like it should do the trick, thanks!

0 Kudos