Select to view content in your preferred language

Caching Error with Parcel Fabric Active Record Automation

146
3
Jump to solution
a week ago
Jessica_Watson
Emerging Contributor

Hello,

I am using parts of this script at this link Parcel Fabric Active Record Automation - Esri Community suggested by @KenGalliher1 . I've pasted an extract of my script below. The code works when there is an active record set in the map like this

Jessica_Watson_0-1749190774837.png

 

and returns the id as expected, however once I turn off the active record like this

Jessica_Watson_1-1749190815334.png

 

using the toggle and re run this code, the same record_id for the 'TEST' record is still returned. I only want the record_id returned when in fact there is an active record. It appears that the cim properties are somehow being cached.

Is there a better way to check for an active record or is this a bug with the cim properties? And help would be much appreciated. Thank you

current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap

map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]

# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)

 

0 Kudos
1 Solution

Accepted Solutions
Chris-Zemp
Esri Contributor

Hi Jessica,

Chris here with the parcel team. Thanks for your question.

You're right, it might make more sense if the ActiveRecord CIM properties returned a NULL object if there is no active record in the map. We will do some internal review on this.

But there is a pretty straight forward way to return a record GUID if the record is actually active.

There is a boolean property called enabled that will be True if the record is active and False if it is not.

You can make use of this property to return the GUID, only if the record is active, like so:

current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap

map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]

# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)

# added logic to only return a record GUID if record is enabled (active)
if parcel_cim_def.parcelFabricActiveRecord.enabled:
    print("Record is active in current map. The GUID is: ", record_id)
else:
    print("There is no active record") 

 

I also made a quick video showing the behavior.

View solution in original post

3 Replies
AmirBar-Maor
Esri Regular Contributor

@Jessica_Watson That makes sense.

We will look into it

Chris-Zemp
Esri Contributor

Hi Jessica,

Chris here with the parcel team. Thanks for your question.

You're right, it might make more sense if the ActiveRecord CIM properties returned a NULL object if there is no active record in the map. We will do some internal review on this.

But there is a pretty straight forward way to return a record GUID if the record is actually active.

There is a boolean property called enabled that will be True if the record is active and False if it is not.

You can make use of this property to return the GUID, only if the record is active, like so:

current_project = arcpy.mp.ArcGISProject('current')
# Get the active map
target_map = current_project.activeMap

map_layers = target_map.listLayers()
parcel_layer = [lyr for lyr in map_layers if lyr.isParcelFabricLayer][0]

# get parcel fabric cim properties to return active record
parcel_cim_def = parcel_layer.getDefinition("v3")
cim_properties = [v for v in dir(parcel_cim_def.parcelFabricActiveRecord) if not v.startswith("_")]
active_record = parcel_cim_def.parcelFabricActiveRecord.activeRecord
record_id = str.upper(active_record)

# added logic to only return a record GUID if record is enabled (active)
if parcel_cim_def.parcelFabricActiveRecord.enabled:
    print("Record is active in current map. The GUID is: ", record_id)
else:
    print("There is no active record") 

 

I also made a quick video showing the behavior.

Jessica_Watson
Emerging Contributor

Thank you, @Chris-Zemp , this worked.

0 Kudos