I have a ModelBuilder model that determines whether a field in a table contains null or duplicate values. The outputs of the model are two integer parameters, one with the count of nulls and one with the count of duplicates.

I have a workflow in Workflow Manager that I would like to integrate the model into in order to implement logic branching.

Is there a way in Workflow Manager to:

  1. Run the model as a step in a workflow
  2. Examine the output of the model and branch into 1 of 2 logical workflow branches.

For 1) I assume that I must run the JTXSteps.ExecuteGPTool custom step, is that correct?

For 2) (How) can I set the return code in the model? Must I refactor the model so that it only has one output parameter, or should I actually cause an error to occur for the return code to be non-zero? How can I use the return code to specify the logical branch to step into?

  • Don't know the answer to this one, but I am interested in the answer. Also...do you know about using sys.exit(n) python statements to return codes that map to conditional return codes in WM? It might save you from having to compile, register a custom DLL for something as mundane as checking for dupes/null. Oct 3, 2012 at 19:15
  • No I hadn't thought of that, if you use something like that I'd be interested in hearing about it. How do you map the return codes to the appropriate next step?
    – blah238
    Oct 3, 2012 at 19:36
  • I'll get something together and add it as an answer. Oct 3, 2012 at 19:51

1 Answer 1

  1. Add an executable step to workflow and configure it with python.exe as the Program and the arguments are your python script plus any WMX tokens that you want (they will accessible in the python script via sys.argv). enter image description here

  2. In your python script, you'll do stuff and based on whatever condition...return a value. I've truncated some of the lines that I think might be sensitive, but you'll get the idea. And sorry for image screen shot of the code--for some reason, the python code was getting formatted horribly.

    enter image description here

  3. Then back in your Workflow, you double-click on the paths(lines) from your execute step to the next workflow step(s) to show path properties. Check the Has Conditional Return Codes checkbox. Add a new return code number that maps to the corresponding sys.exit(n) condition in your python script. Repeat for each of your conditional steps. enter image description here

Credit to Jeremy Mirmelstein (Esri), who helped custom-configure this step and has been infinitely patient with my WMX questions.

  • Great example, thanks. I suppose it should be possible to use sys.exit() within a Calculate Value tool in a model if I wanted to use a model instead of a Python script. I'll have to play around with that.
    – blah238
    Oct 3, 2012 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.