HOW TO

Populate a GUID field with values from a text field in ArcGIS Pro

Last Published: July 18, 2024

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'.

The attribute table view and the GUID values in a text field.

This article describes the workflow to transfer the GUID values from a text field to a GUID field.

Procedure

  1. In ArcGIS Pro, right-click the layer in the Contents pane, and click Attribute Table.
  2. 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.
The Fields view tab and the new Guid data type field.
  1. In the attribute table view, right-click the new field, and click Calculate Field.
  2. 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).
    1. 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>!)
  1. In Code Block, enter the following code.
def ID(guid1):
  import uuid
  return '{' + str(uuid.UUID(guid1)) + '}' 
  1. Click Apply and OK. The new GUID data type field is populated with GUID values from the text field.
The GUID field calculation code block in ArcGIS Pro.

Article ID: 000029353

Software:
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options