diff --git a/entity/Organisation_entity/entityfields/openaroundlocation/stateProcess.js b/entity/Organisation_entity/entityfields/openaroundlocation/stateProcess.js index 129f026470464d303d456ab6851aaecf995c9d52..b9adad9dcc6f3d6bd52266d65651298cbada6a5b 100644 --- a/entity/Organisation_entity/entityfields/openaroundlocation/stateProcess.js +++ b/entity/Organisation_entity/entityfields/openaroundlocation/stateProcess.js @@ -3,21 +3,24 @@ import("system.neon"); import("system.vars"); import("system.entities"); -//use read entity since the lat and lon fields are not loaded by default since they are not needed otherwise -var rowConfig = entities.createConfigForLoadingRows() - .fields(["STANDARD_LAT", "STANDARD_LON"]) - .entity(vars.get("$sys.currententityname")) - .uid(vars.get("$sys.uid")); -var row = entities.getRow(rowConfig); +var recordState = vars.get("$sys.operatingstate"); +var res = neon.COMPONENTSTATE_DISABLED; +var uid = vars.get("$sys.uid"); +if (recordState != neon.OPERATINGSTATE_NEW && recordState != neon.OPERATINGSTATE_EDIT && uid) +{ + //use read entity since the lat and lon fields are not loaded by default since they are not needed otherwise + var rowConfig = entities.createConfigForLoadingRows() + .fields(["STANDARD_LAT", "STANDARD_LON"]) + .entity(vars.get("$sys.currententityname")) + .uid(uid); + var row = entities.getRow(rowConfig); -var lat = row["STANDARD_LAT"]; -var lon = row["STANDARD_LON"]; + var lat = row["STANDARD_LAT"]; + var lon = row["STANDARD_LON"]; + + if (lat && lon) + res = neon.COMPONENTSTATE_AUTO; +} -var res; -if (lat && lon) - res = neon.COMPONENTSTATE_AUTO; -else - res = neon.COMPONENTSTATE_DISABLED; - result.string(res); \ No newline at end of file