Profile Variable $Map is Not Found

1487
9
Jump to solution
02-05-2023 11:39 PM
Labels (2)
Mohamed_Gamal
New Contributor II

I am trying to filter the database by using profile variable $Map in ArcGIS Pro Attribute Rules and I had an Object Not Found Error 

var deviceClass = FeatureSetByName($map, "Communications Device");

Another Question :

I always do this kind of filter using profile variable $datastore. I want only to get the field room from this table, but when printing the results all fields are there

var test="{4EC98101-67C4-44FC-8BF5-C7DF9393AB73}"
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "GLOBALID = @test");
return{"errorMessage":"FeatureSetByAssociation: "+first(devicesRows)};

this screen of the output 

Mohamed_Gamal_0-1675668888242.png

 

var test="{4EC98101-67C4-44FC-8BF5-C7DF9393AB73}"
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject",['room'],false);
var devicesRows = Filter(deviceClass, "GLOBALID = @test");
return{"errorMessage":"FeatureSetByAssociation: "+first(devicesRows)};

the second output 

Mohamed_Gamal_1-1675669155723.png

 

Tags (1)
2 Solutions

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

To post code:

JohannesLindner_0-1674589814049.png

JohannesLindner_1-1674589827880.png

 

 

I am trying to filter the database by using profile variable $Map in ArcGIS Pro Attribute Rules

You can't use $map in attribute rules. Attribute rules work on the database level and can be triggered from different maps (or even without a map at all), so it doesn't make sense to rely on a featureset in a specific map.

Instead, use $datastore if the featureset is in the same database. If not, you have to publish it and load it in using FeaturesetByPortalItem().

 

 

I want only to get the field room from this table, but when printing the results all fields are there

You return the whole feature, so every field is printed. Instead, return only a specific field:

var test="{4EC98101-67C4-44FC-8BF5-C7DF9393AB73}"
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "GLOBALID = @test");
var device = First(devicesRows)
var room = IIf(device == null, "nodevice found", device.room)
return{"errorMessage":"FeatureSetByAssociation: " + room};

Have a great day!
Johannes

View solution in original post

JohannesLindner
MVP Frequent Contributor

Ah, I see now that I misunderstood your second question.

 

I see this behavior in a file gdb. While the Console() command ouputs the right message (empty geometry and only one field [plut OBJECTID]), the error message prints the complete feature, although I didn't load the geometry and the other fields.

var fs = FeatureSetByName($datastore, "TestLines", ["IntegerField"], false);
Console(First(fs))
return {errorMessage: Text(First(fs))}

JohannesLindner_1-1675686379155.png

JohannesLindner_2-1675686509985.png

 

 

In an Enterprise GDB, it works as expected:

var fs = FeatureSetByName($datastore, "Bauwerke", ["BauwerkID"], false);
Console(First(fs))
return {errorMessage: Text(First(fs))}

JohannesLindner_0-1675686241629.png

JohannesLindner_3-1675686698218.png

 

@HusseinNasser2 , any insights?


Have a great day!
Johannes

View solution in original post

0 Kudos
9 Replies
JohannesLindner
MVP Frequent Contributor

To post code:

JohannesLindner_0-1674589814049.png

JohannesLindner_1-1674589827880.png

 

 

I am trying to filter the database by using profile variable $Map in ArcGIS Pro Attribute Rules

You can't use $map in attribute rules. Attribute rules work on the database level and can be triggered from different maps (or even without a map at all), so it doesn't make sense to rely on a featureset in a specific map.

Instead, use $datastore if the featureset is in the same database. If not, you have to publish it and load it in using FeaturesetByPortalItem().

 

 

I want only to get the field room from this table, but when printing the results all fields are there

You return the whole feature, so every field is printed. Instead, return only a specific field:

var test="{4EC98101-67C4-44FC-8BF5-C7DF9393AB73}"
var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject");
var devicesRows = Filter(deviceClass, "GLOBALID = @test");
var device = First(devicesRows)
var room = IIf(device == null, "nodevice found", device.room)
return{"errorMessage":"FeatureSetByAssociation: " + room};

Have a great day!
Johannes
Mohamed_Gamal
New Contributor II

Hi Johannes,

    Thanks for your attention and your fast reply.

Regarding my second question, I know how to print a specific field from the feature my question was about, I had read in the documentation that specifying specific fields to feature class or table is making performance faster, so I thought the object returned from this line should only contain room field.

var deviceClass = FeatureSetByName($datastore, "CommunicationsJunctionObject",['room'],false);

 

0 Kudos
JohannesLindner
MVP Frequent Contributor

Ah, I see now that I misunderstood your second question.

 

I see this behavior in a file gdb. While the Console() command ouputs the right message (empty geometry and only one field [plut OBJECTID]), the error message prints the complete feature, although I didn't load the geometry and the other fields.

var fs = FeatureSetByName($datastore, "TestLines", ["IntegerField"], false);
Console(First(fs))
return {errorMessage: Text(First(fs))}

JohannesLindner_1-1675686379155.png

JohannesLindner_2-1675686509985.png

 

 

In an Enterprise GDB, it works as expected:

var fs = FeatureSetByName($datastore, "Bauwerke", ["BauwerkID"], false);
Console(First(fs))
return {errorMessage: Text(First(fs))}

JohannesLindner_0-1675686241629.png

JohannesLindner_3-1675686698218.png

 

@HusseinNasser2 , any insights?


Have a great day!
Johannes
0 Kudos
Mohamed_Gamal
New Contributor II

Thanks, Johannes it was a fruitful discussion. 

0 Kudos
HusseinNasser2
Esri Contributor

@JohannesLindner  Can you try the filegdb case with Pro 3.1 Beta if you have access? 

We have a known issue where Arcade might sometime fetch all the fields even a subset is provided. 

 

0 Kudos
Mohamed_Gamal
New Contributor II

Unfortunately, I don't have access to Pro 3.1 Beta version.

 

0 Kudos
HusseinNasser2
Esri Contributor

No worries, I confirmed this is fixed in Pro 3.1.

 

HusseinNasser2_0-1675696402487.png

 

JohannesLindner
MVP Frequent Contributor

@HusseinNasser2  I don't have access to the beta. The example above was done in 3.0.3


Have a great day!
Johannes
0 Kudos
GelcysWilliams
New Contributor III

We have been able to use the $map to do the following in AGOL, but our need is for auto-filling certain attributes in Pro as well as in AGOL.  Can you use that FeaturesetByPortalItem() variable to connect to other FCs in other databases on your Portal for use in Intersect and Nearest Neighbor Attribute rules for use in Pro?

0 Kudos