I'm trying to author a Field Maps form calculation expression that will:
Seems straightforward, but doesn't currently work for me on device. The IIf statement below is what is being used as the expression in the form calculation:
//if it's an insert, generate a new GUID value into field INF_GUID
//otherwise use existing value in field
IIf($editcontext.editType == 'INSERT', Guid(), $feature.INF_GUID)
Tested using Field Maps 22.3.1 (both iOS and Android), any assistance would be greatly appreciated!
Solved! Go to Solution.
After doing further research, the original expression does correctly return a new guid value, except in the following condition: if copy feature (geom + attrs) is used in field maps, and the user then immediately edits the geometry of the newly copied feature before saving the new feature. In this scenario, the expression still fails to generate a new guid value.
The following expression accounts for this oddity with the copy features tool:
//if it's an insert, generate a new GUID value into field INF_GUID
//otherwise use existing value in field
//but if Copy Feature tool is used in Field Maps, and then user immediately edits geometry before saving...
//then no Guid is calculated using this expression
IIf($editcontext.editType == 'INSERT', Guid(), $feature.INF_GUID)
//the following expression accounts for this extra wrinkle with copy feature tool
IIf(($editcontext.editType == 'INSERT' ||
($editcontext.editType == 'UPDATE' &&
(IsEmpty($feature.INF_GUID) || $feature.INF_GUID == '{00000000-0000-0000-0000-000000000000}'))),
(Guid()),$feature.INF_GUID)
After doing further research, the original expression does correctly return a new guid value, except in the following condition: if copy feature (geom + attrs) is used in field maps, and the user then immediately edits the geometry of the newly copied feature before saving the new feature. In this scenario, the expression still fails to generate a new guid value.
The following expression accounts for this oddity with the copy features tool:
//if it's an insert, generate a new GUID value into field INF_GUID
//otherwise use existing value in field
//but if Copy Feature tool is used in Field Maps, and then user immediately edits geometry before saving...
//then no Guid is calculated using this expression
IIf($editcontext.editType == 'INSERT', Guid(), $feature.INF_GUID)
//the following expression accounts for this extra wrinkle with copy feature tool
IIf(($editcontext.editType == 'INSERT' ||
($editcontext.editType == 'UPDATE' &&
(IsEmpty($feature.INF_GUID) || $feature.INF_GUID == '{00000000-0000-0000-0000-000000000000}'))),
(Guid()),$feature.INF_GUID)