Select to view content in your preferred language

Map Viewer Web Form - incremental number updates when the feature is moved

208
2
Jump to solution
08-26-2024 03:16 AM
PanGIS
by
Frequent Contributor

Hello!

 

I have a web form that calculates an incremental ID and then concatenates it to form a refNumber.

It works fine until you decide to update the point: let's say the position is incorrect and you need to move it.

this is the code and below are the results: the number should stay the same as it is the same point:

 

 

// Get the current feature's newID field value
var currentID = $feature.newID;

// Check if currentID is null or empty, meaning this feature needs a new ID
if (IsEmpty(currentID)) {
// Get the maximum value of the newID field from all features in layerName
var maxID = Max(FeatureSetByName($datastore, "layerName", ["newID"]), "newID");
return maxID + 1;
} else {
// If currentID is already set, return the existing currentID
return currentID;
}

 

 

 

create a point with ID 5 and then moved it becomes 6

PanGIS_0-1724667431043.png

Any idea?

Thanks!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RhettZufelt
MVP Notable Contributor

Think you just need to check the $editcontext.editType.  If "INSERT", calculate ID, if "UPDATE", just move point without calculating.

Basically the same as this post.

R_

 

View solution in original post

0 Kudos
2 Replies
RhettZufelt
MVP Notable Contributor

Think you just need to check the $editcontext.editType.  If "INSERT", calculate ID, if "UPDATE", just move point without calculating.

Basically the same as this post.

R_

 

0 Kudos
PanGIS
by
Frequent Contributor

Thank you @RhettZufelt .

 

It worked 😊

0 Kudos