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))
}