Hi,
I am new to Data Loading Tools. Can I add domains to TargetField (existing in target GDB) based on SourceSchema fields if the source does not have domains? @TedHoward2
Solved! Go to Solution.
Yes that’s exactly how it works. I would suggest adding custom expressions to user.py instead of base.py. This will maintain your expressions if you ever run the Update Data Loading Workspace Schema tool.
Not in data loading tools. They only are for the transfer of data, not schema.
I want data transfer only but assign domain to a field based on source field values
There is a new capability coming in 3.3 that will create an coded value domain from the values in the column. You could leverage that after transferring the data. At 3.2 and before, you will need to script the process.
The term "assign domain" is throwing us off I think. Do you mean load values to a target field that already has a domain? There are a couple ways to do that. As Mike mentions you could script it by writing a python expression to transfer values. You could also create your own Lookup sheet and map source field(s) values to a target value. The Source field does not have to have a domain.
Thanks for the reply @TedHoward2 ,
"Assign Domain" means "Domains" already exist in the target geodatabase and I have to assign on the basis of source field values. Can I use the base.py to assign domain codes to the target like the following:
def assign_domain(new_level: int, new_color: int, new_line_wt: int, new_linetype: str) -> int:
if new_level == 2 and new_color == 3 and new_line_wt == 2 and new_linetype == "Solid":
return 1
else: return 2
and call the function assign_domain(!NewLevel!, !NewColor!, !NewLineWt!, !NewLinetype!) in Expression column of TargetField
Yes that’s exactly how it works. I would suggest adding custom expressions to user.py instead of base.py. This will maintain your expressions if you ever run the Update Data Loading Workspace Schema tool.