Summary
Values in a global unique identifier (GUID) field are normally used to track geodatabase replication and for other identification purposes. These values are managed manually and can be created through Python. In some instances, GUID values are stored in a text field in ArcGIS Pro, causing certain tools or to analysis fail to run. In this example, the GUID values are stored in a text field named 'GUID'.
This article describes the workflow to transfer the GUID values from a text field to a GUID field.
Procedure
- In ArcGIS Pro, right-click the layer in the Contents pane, and click Attribute Table.
- In the attribute table view, click Add Field, and create a new field with GUID data type. Refer to ArcGIS Pro: Create a field and apply a domain and default value for instructions. In this example, the new GUID field name is GUID2.
- In the attribute table view, right-click the new field, and click Calculate Field.
- In the Calculate Field pane, ensure Python 3 is selected for Expression Type, and configure the Expression parameter to populate the new GUID data type field (GUID2) with values from the text field (GUID).
- In the expression box, enter the following code. Replace <GUID text field> with the name of the text field containing the GUID values.
ID(!<GUID text field>!)
- In Code Block, enter the following code.
def ID(guid1):
import uuid
return '{' + str(uuid.UUID(guid1)) + '}'
- Click Apply and OK. The new GUID data type field is populated with GUID values from the text field.