Field Maps, Offline Map, Arcade Calculation Expression Fails

2872
6
Jump to solution
02-17-2023 09:33 AM
kmsmikrud
Occasional Contributor III

Hello,

I am struggling trying to figure out why this calculation is failing in the offline downloaded map in field maps.  It is using the GetUser, but this does seem to be working fine in the offline map.

I am trying to generate a sample id based on the username initials (initials are from a table in the map with 2 fields for initials and other username). The next part of the expression queries the feature layer for the records submitted by that user for the max record and adds 1.

Below is the expression that is failing in the offline map, it works in the online map. When I look in the Field Maps troubleshooting, I see this message [AR CADE] Expression failed to evaluate: ....Error: Domain=com.esri.arcgis.runtime.error Code="Arcade expression is invalid. "Userinfo={NSLocalizedFailureReason= Arcade evaluation error. Evaluation_error_code::unexpected_null_value Line:11,.....}

I would really appreciate any insight. So frustrating to see it work on the online map (on the device) but not the offline. @Anonymous User  

Update: Our workflow is to create an offline map using the AGOL web map settings to create an offline area. In this offline map the expression fails to calculate. I also created an offline map on the device in Field Maps, what's interesting is this expression calculates, but not a 100%. It adds the user initials correctly but doesn't find the max 'CID' attribute value to increment. Are the features truncated to the offline map view, so not all attribute records are saved to the device?  I have opened a tech support case as another attempt to get clarification.

Kathy

 

 

 

 

 

 

var user = GetUser(FeatureSetByName($map, "Herring Samples:")).username
Console(user);

var sql1 = "username = '" + user + "'";
Console(sql1)

var tbl_ini = FeatureSetByName($map,"tbl AGOLuser initials");
var user_ini = Filter(tbl_ini, sql1);
var ini = First(user_ini)['initial'];

Console(ini);

var sql2 = "Creator = '" + user + "'";

var sample = FeatureSetByName($map,"Herring Samples:", ['Creator','CID'], false)

var user_rec = Filter(sample, sql2);

if (!IsEmpty(user_rec)){
    var un_id = max(user_rec, 'CID')
    Console(un_id)
    un_id = un_id + 1
    Console(un_id)
    if (Count(Text(un_id)) < 2){
        var pad = Concatenate(Text(0), Text(un_id))
        return Concatenate(ini,Text(0), Text(un_id))
    } else {
       return Concatenate(ini, Text(un_id))
    }
} else {
    return Concatenate(ini,Text(01))
}

 

 

 

 

 

 

 

This calculated expression is working in the offline map and parsing the user initials (first/last name) from the Get User, but ideally we would like the middle initial to remove potential duplicates.

 

 

 

 

 

 

var user = GetUser(FeatureSetByName($map, "Herring Samples:")).username
Console(user);

var sql1 = "username = '" + user + "'";
Console(sql1)

var sampler = (Split(user,'.'))
var sampler_id = Upper(Concatenate(Left(sampler[0],1),Left(sampler[1],1)))

var sql2 = "Creator = '" + user + "'";

var sample = FeatureSetByName($map,"Herring Samples:", ['Creator','CID'], false)

var user_rec = Filter(sample, sql2);

if (user_rec != null){
    var un_id = max(user_rec, 'CID')
    Console(un_id)
    un_id = un_id + 1
    Console(un_id)
    if (Count(Text(un_id)) < 2){
        return Concatenate(sampler_id,Text(0), Text(un_id))
    } else {
       return Concatenate(sampler_id, Text(un_id))
    }
} else {
    return Concatenate(sampler_id,Text(01))
}

 

 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
kmsmikrud
Occasional Contributor III

BUG Logged

Esri tech support was able to reproduce the issue where the arcade expression fails in the AGOL webmap settings generated offline map but the expression works in an offline map generated from the device. In our case we are using iOS, so I'm not sure of other systems.

BUG-000155887 has the details, so hopefully the developers can fix soon as for our organization we prefer to have the pre-planned offline maps available for download rather than having the surveyor generate their own area.

Also lesson learned, if an expression calculates online and then doesn't in the offline map try both the AGOL generated offline maps and the device because there are differences on how these are generated.

Thanks

View solution in original post

0 Kudos
6 Replies
kmsmikrud
Occasional Contributor III

Update: 

There seems to be a difference between how the AGOL web map settings generate an offline map and handles the arcade calculated expressions versus Field Maps device (generate an offline area).

I have two similar arcade expressions that fail to calculate in the offline map generated in the web map settings, but works in the offline map created on the device.

Its my preference to generate the offline map extents using the AGOL web maps settings for the biologists, its one less step on their end.

Please review the difference so the expressions work using both methods. I would be happy to add you to an AGOL group for testing.

Thanks,

Kathy

 

0 Kudos
kmsmikrud
Occasional Contributor III

BUG Logged

Esri tech support was able to reproduce the issue where the arcade expression fails in the AGOL webmap settings generated offline map but the expression works in an offline map generated from the device. In our case we are using iOS, so I'm not sure of other systems.

BUG-000155887 has the details, so hopefully the developers can fix soon as for our organization we prefer to have the pre-planned offline maps available for download rather than having the surveyor generate their own area.

Also lesson learned, if an expression calculates online and then doesn't in the offline map try both the AGOL generated offline maps and the device because there are differences on how these are generated.

Thanks

0 Kudos
Adam_Bourque
Occasional Contributor

My workflow with pop-up pass over values from field maps to the "inbox" works online but not offline. I have tried a pre-set offline area and/or using the self created offline area on device. Also tried "Refreshing" the inbox before hand and still no luck.. If you would like to see for yourself I'd be happy to show you, I hope this is fixed soon! @kmsmikrud 

0 Kudos
JonSwoveland
Occasional Contributor

Hi Kathy,

I found your post while looking for a similar solution to generate a unique human-readable record id for features created by an offline app.  In my case, the app is VertiGIS Studio Mobile, not Field Maps, but it uses the exact same gdb synch mechanism.  Like your case, I want to generate an id that is a combination of a "Task Type" key, followed by (Max Record + 1).  I'm curious if you got this working offline, and if so, does the field value get calculated only upon data synchronization? If calculated while offline, using (Max Record + 1)  could lead to duplicate ids (assuming the possibility of multiple concurrent field workers).

Thank-you,

Jon

0 Kudos
kmsmikrud
Occasional Contributor III

Hi @JonSwoveland ,

We did get this to 'sort' of work. The unique ID is by sampler and then their own sample counts so the max record in our case is specific to each user and I created a field that increments for each user with their sample count and increments with each record submitted. This helps with folks working offline and querying only for that sampler's max count. However, the table that gets downloaded offline is specific to the offline area extent so we did have someone that was sampling in another management area (jet plane distance away) return to their area and I had to add in specific code for their user name to compensate for the max record since those samples weren't included in their 'area' offline map.

According to @JustinReynolds , the arcade expressions execute when the data is submitted for each record and shouldn't change. We didn't fully test this but I did have someone say twice that when they returned to Wi-Fi and synched data their record count updated (this was prior to us implementing the max id per sampler).  I actually posted on this but never got a response, but I also do believe them since they were doing a lot of quality control at the time. I'm not sure if this info is useful or can be applied but the max record count in our situation works offline when it is combined with sampler initials and only their records.

I'll have to to look up the VertiGIS Studio Mobile.

Thanks,
Kathy

JonSwoveland
Occasional Contributor

Thanks for the detailed response, Kathy, I appreciate it!

0 Kudos