Select to view content in your preferred language

FeatureSet not working offline in Field Maps

3203
13
Jump to solution
04-10-2022 02:00 PM
Scott_Sambell
Frequent Contributor

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!

 

@JeffShaner 

Scott
13 Replies
KelseySmuczynski
Occasional Contributor

Hey Rhett,

Thanks for the quick reply. I tried your suggestion (code below), but still received the same error.

 

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 (IsEmpty(well)){
return null
}
return well.Well_Name

 

Also, just to clarify, my initial code (below, just in case) was successfully populating fields in my inspection form with info from my related feature class. It stopped working when I created and used an offline map for data collection.

 

//Initial code that was successful in non-offline mode.

var ref_guid= $feature.GUID // <---No upper casting

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

 

 

Kelsey

0 Kudos
KelseySmuczynski
Occasional Contributor

Oops, looks like I missed applying the IsEmpty function to the ref_guid in line 3. I updated my code as shown below and it tested without issues. I'll still need to see if the changes applied to my offline maps, but will report back soon.

 

UPDATE: IT WORKED!

Thanks, @RhettZufelt and @Anonymous User . You guys are rock stars.

 

var ref_guid= upper ($feature.GUID)

if(IsEmpty(ref_guid)) { //<-- applied IsEmpty()here
return null
}

var wells_fs=FeatureSetByName($map,"Wellsites2")
var wells_filter = Filter(wells_fs, `GlobalID = '${ref_guid}'`)
var well = First(wells_filter)

if (IsEmpty(well)){
return null
}
return well.Well_Name

 

0 Kudos
Samuel_McAuley
Occasional Contributor

I am experiencing a similar issue with FeatureSetByName not working offline. In this example, I am attempting to use the user property 'username' to lookup a staff ID number in a standalone lookup table within the map. I know that only certain user properties are available offline using GetUser($layer), but username is definitely one of them as I can return that no problem. The issue is when I try to filter the lookup table using that property. Online it executes without a hitch, however offline it is returening 0 records. I have tried returning the staff ID and also just the count of records returned from the filter function. The count consistently returns 0 when offline and 1 when online.

Below is my code snippet. 

 

var me = GetUser($layer).username
var lut = FeatureSetByName($map,"staff_LUT")
var filtered = Filter(lut, 'label2 = @me')
return First(filtered).name

In addition to this, I tried to just reference the table and return the count of records in it (see below), and when online it returned 184 as expected, however offline it returned 0.

return count(FeatureSetByName($map,"staff_LUT"))

Any advice would be greatly appreciated

0 Kudos
RhettZufelt
MVP Notable Contributor

there are some issues with GetUser() in Field Maps app.  Try this to see if it gets the username for you:

var me = GetUser(FeatureSetByName($map,"staff_LUT")).username
var filtered = Filter(lut, `label2 = '${me}'`)

Also, remember that if offline, a count (or any other operation) will only work on the features that are currently 'downloaded' into you offline area.  Is it possible that the offline are you are testing is outside of the 184 points in the data?

R_

0 Kudos