Enhance Table To Domain tool to coerce datatype of incoming code to datatype of the Domain Code

1398
1
04-09-2021 11:44 AM
Status: Open
Labels (1)
AngelaDeegan
Occasional Contributor

Table to Domain fails to import records from Excel that have integers in the code column when the destination domain has a code datatype of short integer. This is the case even when the integers are within the range of short integers (-32,768 to 32,767).

We are working on migration to Utility Network. In doing so, we need to duplicate some of our existing domains in UN. However we need many of them to have data type "short" in UN - instead of data type "text" which they currently have. To do this we have tried the following:

  1. Create the new domain in WaterDistribution_AssetPackage_Change.gdb - making sure to classify the code attribute as data type short integer.
  2. Create a copy of the existing domain in Excel using Domain to Table making sure all the codes are integers that qualify as short integers.
    (Note that this Excel spreadsheet does double-duty because we can also paste its contents into the relevant domain sheet in the DataMapping spreadsheet for mapping the old text codes to the new integer codes. These DataMapping spreadsheets have names such as Main-WaterLine_Water Main.xlsx)
  3. Run Table to Domain to import the code and description from the Excel Spreadsheet  into the new domain.

Step 3 fails with Error 000307 The input field type does not match the field type of the existing domain.

In the attachment, you can see that after the tool failed, I verified that the codes were true numbers (see cell D2 in the Excel file). I had also previous tested manually entering one of the codes and its corresponding description into the new domain and that was successful.

I had submitted this as a bug (#02779308) and was informed that the error is due to the values in Excel being classifed as data type double, not short and that it would require a work-around involved multiple additional steps to get this to work.

Rather than have to use the work-around, this idea is that the Table to Domain tool gets enhanced so that it attempts to coerce input codes to the datatype of the domain code. With this enhancement, I would expect an input code of datatype double should successfully migrate to a domain code datatype of short integer, provided that the input codes are in the form of whole numbers that are within the range -32,768 to 32,767.

 

 

1 Comment
KoryKramer

Hi @AngelaDeegan While you have a valid idea here, I thought I'd share the following in hopes of keeping you moving ahead in a somewhat straightforward and not too egregious way...

Once you have the Excel sheet in Pro, export it to csv and set the output datatype for the code as Short.

KoryKramer_0-1618001987971.png

The csv now has the Short datatype for Code.

KoryKramer_1-1618002057745.png

Then run Table to Domain using the csv table as input.  Should work:

KoryKramer_2-1618002183690.png