I am ultimately trying to merge my buffered layers together after I've created and calculated a field within each buffer.
My steps within my submodel are
1: Iterate Row Selection from the Bus Route table list, which produces a Value
2: Select by Attribute from the Bus Stop layer the Value that's currently being iterated
3: Buffer the Bus Stop selection, and dissolve into single feature
4: Add Field to the newly created Stop Buffer layer
5: Calculate as text the newly created field (expression is '%Value%')
6: Collect Values
My steps within my Main Model are
1: Run the submodel
2: Merge the collected values
Each time I run it, the field that was created in the buffer is not there. How do I include this newly created field in my Merge?
The issue here is that your field map for the merge is calculated at validate time, before any buffers or add fields happen in the submodel.
I can think of two things to try:
Thanks for the advice Curtis. Because I would like to make my process (which will include other submodels) as much of a one-button click as possible, I am more interested in the Calculate Value tool you mentioned. Unfortunately, I don't have any Python scripting experience. Is it possible to help explain what my script would look like? The field I'm adding to the buffer (in my submodel) is Text, because the express bus routes are denoted with an "X", which are also denoted the same way in the Dec2018 Excel file, as well as within the Dec2018Stops point feature class.
Thanks again!
I'm a little confused because I don't get why you are adding a field that is already there.
The python code you need to do to create a field map at runtime would use the FieldMappings object.
FieldMappings—Help | ArcGIS Desktop
Here's a script for the Calculate Value tool. NOT tested.
# expression
fmap(r"%Output Values%")
# code block
import arcpy
def fmap(cvalues):
cvals = cvalues.split(";")
fms = arcpy.FieldMappings()
for ds in cvals:
fms.addTable(ds)
return fms.exportToString() # Data type Field Map, connect to Merge tool
Field Mappings variable as a parameter not working in 10.5.1