Select to view content in your preferred language

Get GlobalID of current record

1265
5
Jump to solution
08-11-2021 07:54 AM
DeanAnderson2
Frequent Contributor

Is there an arcade or some other function/process that will allow me to get/save the GlobalID of the current ActiveRecord. It appears that the active record (when you create a new record) is not selected and is only selected when you use the "select record" or "attribute rule showing selected record" in the record menu. 

For example, if I have a record named "TEST1" and use the "select record" the selection set is "TEST1".  However, when I go to manage records and select another recent record "TEST2" and set it the active record the selection set in the records table is still "TEST1" until I use the "Select Records" or "attribute rule showing selected record" in the records menu. 

I have other feature classes that I want to associate with the current active record (cartographic lines, annotation classes, etc).  Ultimately I would like to create an attribute rule that does this but not having that I think I could do it with a workflow task. 

 

 

0 Kudos
1 Solution

Accepted Solutions
DeanAnderson2
Frequent Contributor

I have figured out a simple work around.  You can get the active record globalid for the record from one of the layers that participates in the fabric if you click the "Show Only Active".  This sets up the definition query which you can get the ActiveRecordNumber from.  In the following bit of code the Taxlot_Lines is a feature layer that is part of the fabric.   RecordNumber is the final variable that contains the globalid of the active record. 

aprx = arcpy.mp.ArcGISProject("CURRENT")
Map = aprx.activeMap
mapTaxlotLineLyr = Map.listLayers("Taxlot_Lines")[0]
TaxlotLineLayerWhereClause = mapTaxlotLineLyr.definitionQuery

RecordNumber = TaxlotLineLayerWhereClause.split('{')[1]
RecordNumber = RecordNumber.split('}')[0]

 

View solution in original post

5 Replies
AmirBar-Maor
Esri Regular Contributor

@DeanAnderson2 

If you know the name of the record (e.g. 'TEST 1') you can use the Arcade 'Filter' method to create a feature set, then take the first feature in the set (it should only contain one feature).

You will have to check if it is empty.

 

I didn't verify the following expression but it should/could look similar to this:

var recordsFS = FeatureSetByName($datastore, "ParcelFabric_Records",['Name'], true);
var recordName = 'Test1';
var sql = "Name = " + "'" + recordName + "';
var activeRecord = First(Filter(parcelsFS, sql));

 

An 'Active Record' is specific to ArcGIS Pro and to the Active Map View.

Would the above work?

If you need to know the active record without knowing the record name, we could consider adding a $map.ActiveRecord method.

 

 

DeanAnderson2
Frequent Contributor

Thanks for looking at this.  Your second statement is correct, I do not know that active record's name.  The $map.ActiveRecord would be great to use.  Does this exist?  If so I am not sure how. Currently I have created a task that the first step is to select the active record and from that task,  I pick up the recordname and globalid as attributes for the selected record to use later in the task workflow.  This seems to work OK but ties me to a task process and that maybe ok.  Once this is done I am working on automatically filtering the related feature classes for just that record (based on filter of globalid - which I have as an attribute in each feature class).  I then will have a palate of tools that when used will automatically calculate the globalid for each feature as it is added.  Re-reading this it may not be too clear (sorry).  So backing up,  being able to use the $map.ActiveRecord would be great. 

0 Kudos
AmirBar-Maor
Esri Regular Contributor

Hi Dean

We actually had this in our backlog but ran into the following issue:

'Active record' is known in the context of $map (each Pro client map might have a different active record).

Attribute Rules work in the context of $dataStore = they are not specific to any client and work in the feature class level in the geodatabase.

So the problem is that an Attribute Rule cannot use a $map. 

I cannot see how this can be solved for attribute rules.

Tasks, as you have noted, is viable.

0 Kudos
DeanAnderson2
Frequent Contributor

I have figured out a simple work around.  You can get the active record globalid for the record from one of the layers that participates in the fabric if you click the "Show Only Active".  This sets up the definition query which you can get the ActiveRecordNumber from.  In the following bit of code the Taxlot_Lines is a feature layer that is part of the fabric.   RecordNumber is the final variable that contains the globalid of the active record. 

aprx = arcpy.mp.ArcGISProject("CURRENT")
Map = aprx.activeMap
mapTaxlotLineLyr = Map.listLayers("Taxlot_Lines")[0]
TaxlotLineLayerWhereClause = mapTaxlotLineLyr.definitionQuery

RecordNumber = TaxlotLineLayerWhereClause.split('{')[1]
RecordNumber = RecordNumber.split('}')[0]

 

AmirBar-Maor
Esri Regular Contributor

Clever @DeanAnderson2 

We are thinking of exposing it on the definition query UI... but you manage to find it using code.

If you use a task you can have step 'n' create the Active Record and step 'n+1' run your python script to extract the Active Record.

0 Kudos