How to include domains with the "Add Field" tool in Model Builder

1575
3
07-22-2019 08:37 AM
Katie_Clark
MVP Regular Contributor

Hello,

I am editing an existing model in Model Builder. The model takes a feature class as input and adds dozens of fields to it that are part of a standard template. Some of these fields require domains so that drop down options can be utilized once the feature layer is published to ArcGIS Online. These are all standard as well and I would love to add them to the model so that domains don't have to be added every time a new data set it published that has used this model. 

What I am stuck on is exactly how to add the domains. I see the "Field Domain (optional)" field at the bottom of the tool properties, but I'm not sure where it "looks" to reference the domains. The input for this model could be any feature class that the user wants to add these fields to, and would not necessarily be coming from the same geodatabase. Is that something I would have to require (adding the layer to a designated geodatabase) before running the tool? Or could I incorporate that into the tool?  

I am new to Model Builder, so I appreciate any help! Thank you!

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
3 Replies
LanceCole
MVP Regular Contributor

Katherine Clark

You are correct.  You would need to add the domains to your database before using this tool.  Take a look at: A quick tour of attribute domains or Creating a new coded value domain.

You would then be able to type in the domain name to be added to be used by the field.  For example I have a "Yes_No" domain in my database that limits the options to Yes or No.  I would type in Yes_No in the Field Domain input box.

Katie_Clark
MVP Regular Contributor

Ok, is there a way I would be able to incorporate this into the model so the end user could enter any data set and not need to be concerned with adding it to the "template" geodatabase with the domains? 

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
LanceCole
MVP Regular Contributor

Katherine,

If you need to use the a domain it would need to be added to the database.  You do not need to use a domain but users would not be limited to the inputs allowable to the field. 

You can check to see if the domain exists and add it if needed from model builder.  Take a look at Create Domain and Add Coded Value to Domain although this may be better performed using python script in model builder.  Emma Hatcher's‌ post in Add Multiple Fields Quickly with Domains to Add Fields tool has a great reference.