We added calculated expressions to several of our clients' Field Maps after promising that they would have all the functionality now in smart forms that we have been raving about. Everything works perfect using Field Maps online but when we did the final test (download an offline area and sync test) we discovered that the FeatureSet function does not work offline. We tried it on several different Android and iOS devices on several different webmaps. This is an absolute showstopper for us. Is this a bug or a known limitation? We need to know asap so we can explain to the clients why they aren't getting what we promised
Here is an example of how we use FeatureSetByName:
var tblparent = FeatureSetByName($map, "Trap locations",['OBJECTID','Easting_Northing','GlobalID'],False);
Maybe other FeatureSet functions work but FeatureSetByName($Map,...... doesn't? Any explantation i could get would be much appreciated.
Thanks!
Solved! Go to Solution.
@Scott_Sambell While we investigate a full fix, there's a potential workaround. The issue appears to be related to case sensitive GUID value comparisons. If you cast your foreign key (the GUID) to upper, it should work.
var recordGUID = upper($feature.ASSETGUID); // <------ ALTERATION HERE
var recordSet = $featureSet;
var subset = filter(recordSet,`ASSETGUID = '${recordGUID}'`);
var ordered = orderby(subset,'InspDate DESC');
var firstInspec = first(ordered);
if (IsEmpty(firstInspec)) {
return 0;
} else {
return firstInspec.PRESSURE;
}
I tested this in my own map and it seemed to work.
We reproduced this in-house and have opened an issue to investigate further.
Thanks Aaron!
@Scott_Sambell While we investigate a full fix, there's a potential workaround. The issue appears to be related to case sensitive GUID value comparisons. If you cast your foreign key (the GUID) to upper, it should work.
var recordGUID = upper($feature.ASSETGUID); // <------ ALTERATION HERE
var recordSet = $featureSet;
var subset = filter(recordSet,`ASSETGUID = '${recordGUID}'`);
var ordered = orderby(subset,'InspDate DESC');
var firstInspec = first(ordered);
if (IsEmpty(firstInspec)) {
return 0;
} else {
return firstInspec.PRESSURE;
}
I tested this in my own map and it seemed to work.
Thanks Aaron this is going to be amazing if it works. We'll give it a go today and let you know how we go.
thanks so much!
Looks like you've done it Aaron! Its working offline and syncing.
Thanks so much, you are a legend. Can't wait to get it out there and start using it!
Hi Aaron,
I also have the issue of my calculated expression not working in offline mode. I updated my expression by casting my GUID as you suggested, but when I tested it I received an error message, Execution Error: Error. Below is my code (with the casted GUID) that threw the error. Also attached is a screenshot with the error message.
var ref_guid= upper ($feature.GUID)
if(ref_guid == null) {
return null
}
var wells_fs=FeatureSetByName($map,"Wellsites2")
var wells_filter = Filter(wells_fs, "GlobalID = @ref_guid")
var well = First(wells_filter)
if (well == null) {
return null
}
return well.Well_Name
Any suggestions on how best to resolve or work around this issue?
Hi Aaron,
Just wanted to say a big thank you for this suggestion as it has helped me immensely. Last week I was pulling my hair out as I've been trying to pass globalids to the parentglobalid field in another feature using the intersection function so I could create relationships between the two features if they intersect (save the user having to add related records manually). I kept finding that the globalid would calculate sporadically and couldn't work out what the issue was. In my case I found that using the Lower() function on my globalid has solved it so again big thanks for this, it's been a life saver!
Thanks
Anthony
@WillyG Try this.
Testing == null does not seem to catch null/empty values.
What happens if you replace the two if statements with similar code as below (and in Aarons post above):
if (variable == null){
with
if (IsEmpty(variable )) {
Also, look at your filter statement. It appears as if you are just filtering for "GlobalID = @ref_guid" which would only match if the value of that cell = "@ref_guid" and not substituting the variable value.
Suspect it is looking for something more like the previous examples in this post:
var subset = filter(wells_fs,`GlobalID = '${ref_guid}'`);
R_