[GIS] How to hold/collect values in an iterated modelbuilder

arcgis-desktoperror-000725iteratormodelbuilder

I'm using modelbuilder to do upstream traces from several points/flags in a feature class. I'm iterating each point in the fc using the feature selection iterator so that I can calculate/transfer the inline variable/point ID to the trace results. My question is, I have the output of the trace tool connected to the collect values tool which then outputs to the merge tool. I want the merge tool to run only after all points have been iterated/traced and output into the collect values tool. I thought this was the point of the collect values tool, that it would hold/collect all iterations and after the iterations were complete, only then would it continue to the next tool. Currently the model iterates through all tools including the merge tool which then puts the error:

Failed to execute. Parameters are not valid.
ERROR 000400: Duplicate inputs are not allowed
WARNING 000725: Output Dataset: Dataset E:\Workspace\ScratchWorkspace.gdb\Merged_SSO_Assets already exists.
Failed to execute (Merge).

I'm guessing this error is due to a merge being performed at each iteration because when I run each tool individually in sequence, the model runs correctly and w/out errors. I've tried using preconditions but they have not resolved the issue, I could be using the wrong preconditions.
Model Screenshot

Best Answer

You need to put the model up to and including the collects value tool in its own model and expose the collects tool as a parameter. Then put that SUB model into a model and connect its output to your merge tool.

Related Question