In WAB edit widget when you create a feature it sends a request to the rest end point under the applyEdits and uses the adds function something like this.
Now all it is doing a storing the geometry and creating the objectID in the database, but it is sending all the other fields as null. On the database end I am using SQL 2008 R2 server and have set up a trigger to autopopulate the LeakNumber and FacilityID on insert of a new row and I have checked directly after the operation and it does autopopulate those two fields. But as soon as I update another field in the WAB editor widget the next command WAB sends is again under the applyEdits rest end point but this time using the update function, something like this:
So the wab app builder application doesn't know that the database set the FacilityID and LeakNumber fields, so when it send the update it overwrites them back to null. So what I have learned is each time a field is updated it sends an update for all fields. I originally have the LeakNumber field visible and editable, then I made it not editable, then hid it completely thinking that might stop it from sending the null values, but no luck. If I go directly to the rest endpoint and send an update that does not include anything for the LeakNumber or FacilityID fields they do not get overwritten and the update for the field still succeeds.
I am trying to understand why this might be necessary, but can't come up with a reason. In my mind it would make more logical sense to only send the update for the field(s) you are changing. That said there may be a a simple explanation I don't see.
If I could I would not use the trigger at all, but I have an existing database of leaks with unique numbers and I need to continue to populate that number without creating duplicates. Any suggestions on how to avoid WAB overwriting those fields or suggestion on a different way to get the uniqueID into the database would be much appreciated.
Also does anyone know if WAB developer edition allows you to determine what is sent to the rest endpoint in the editor widget?