Select to view content in your preferred language

Model Builder - Only run if it will complete successfully

814
3
09-18-2024 10:57 AM
LukeGilner1
Frequent Contributor

Hi Everyone,

I have a fairly complex model with several joins, calculate fields, remove joins, appends, etc.  I have a bunch of preconditions to check that certain attributes are filled in correctly before the model processes run (otherwise the model will fail).  However, there are times the model will still fail for other reasons (mostly while building it through trial and error).  When it fails, the first parts of the model still do what they're supposed to and update attributes or whatever, but if it fails I would rather that nothing completes, and everything goes back to its original state.  Is there a way to run the model as a "trial" to see if it will complete successfully before actually performing all the operations?  Almost like a precondition to run the model is that it will complete successfully without errors or warnings.  Is there something I can put at the end of the model that says, if model completes then perform all the operations, if not then do nothing?

I am using hosted feature services in Pro 3.3.

0 Kudos
3 Replies
Nick_Creedon
Frequent Contributor

This would be interesting to know, I ended up turning my model builder into a script then added if statements at the end of each tool that runs so that it would terminate the script if one tool failed, this keeps if from running the next tools down the line. 

0 Kudos
Adam_blaine
Occasional Contributor

Interesting thread. I'm interested in the opposite: if the tool fails, I want the model to keep going instead of terminating. My use case is that I have a python script as a tool that stops a locator service, runs the rebuild address locator tool, and then regardless of success or failure of the update, it needs to turn that service back on instead of terminating the model completely. The important thing to note here is that it would likely continue if I didn't have the precondition set, but the precondition is required to enforce it to run in a specific order.

ModelBuilder modelModelBuilder model

0 Kudos
Nick_Creedon
Frequent Contributor

Having the option to run model regardless of errors or not run the model because of errors might be best ask. There are lots of different scenarios where both cases would be useful. 

One of my models deletes all features then does a spatial join based off of attributes, if the schema changes for any layer part of the join, then the join fails but the delete feature tool already ran so now I have an empty feature layer and I have to pull data from a backup. I could probably add preconditions, I haven't done too much more with it, but this is just one scenario.

0 Kudos