3liz / lizmap-web-client

Transfer a QGIS project on a server, Lizmap is providing the web interface to browse it
https://www.lizmap.com
Mozilla Public License 2.0
259 stars 143 forks source link

Expression to populate one field based on another field value does not work #2540

Closed josemvm closed 1 year ago

josemvm commented 3 years ago

What is the bug?

i'am using a case expression for default value

imagem and when i use edition form on qgis desktop it works as expected imagem but not on lizmap imagem

lizmap plugin version: 3.6.3

Steps to reproduce the issue

.

Lizmap version

3.4.6

QGIS desktop version

3.16.10

QGIS server version

3.16.10

Operating system

Ubuntu 20.04

Browsers

Firefox

Browsers version

93.0

Relevant log output

No response

josemvm commented 3 years ago

qgis server logs:

the expression appears like this:


09:47:58 INFO Server[434543]: EXPRESSIONS:{"descricao":"CASE  \r\nWHEN \"natureza\"  = '3101' THEN 'Inc\u00eandio Florestal' \r\nWHEN \"natureza\"  = '3103' THEN 'Inc\u00eandio Mato'  \r\nWHEN \"natureza\"  = '3105' THEN 'Inc\u00eandio Agr\u00edcola' \r\nWHEN \"natureza\"  = '3301' THEN 'Queda de \u00c1rvore'\r\nWHEN \"natureza\"  = '3311' THEN 'Queda Elementos de Constru\u00e7\u00e3o'\r\nWHEN \"natureza\"  = '3313' THEN 'Movimento de Massa'\r\nWHEN \"natureza\"  = '3315' THEN 'Inunda\u00e7\u00e3o por precipita\u00e7\u00e3o intensa'\r\nWHEN \"natureza\"  = '3329' THEN 'Queda de Estrutura'\r\nWHEN \"natureza\"  = '9101' THEN 'Queda de Neve'\r\nEND"}
Gustry commented 3 years ago

Any other logs which might help ? (IE a few lines more after this one), especially the return of this request ? What QGIS is returning ?

josemvm commented 3 years ago

10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap_web_client%2Flizmap%2Finstall%2Fma%2FeventosExtremos.qgs
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi?service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING: service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: REQUEST_METHOD: GET
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:GetServerSettings
10:09:39 INFO Server[434543]: SERVICE:LIZMAP
10:09:39 WARNING [434543]: Service CADASTRE is not registered
10:09:39 INFO Lizmap[434543]: Sending JSON response : {'qgis': {'version': '3.16.10', 'name': 'Hannover', 'version_int': 31610}, 'gdalogr': {'name': 'GDAL 3.0.4, released 2020/01/28', 'version_int': '3000400'}, 'services': ['WMS', 'WFS', 'WCS', 'WMTS', 'ATLAS', 'EXPRESSION', 'LIZMAP'], 'lizmap': {'name': 'Lizmap', 'version': '3.6.3'}}
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 2 ms
10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap_web_client%2Flizmap%2Finstall%2Fma%2FeventosExtremos.qgs
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi?service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING: service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: REQUEST_METHOD: GET
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:GetCapabilities
10:09:39 INFO Server[434543]: SERVICE:ATLAS
10:09:39 INFO Server[434543]: VERSION:1.0.0
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 1 ms
10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING:
10:09:39 INFO Server[434543]: CONTENT_TYPE: application/x-www-form-urlencoded
10:09:39 INFO Server[434543]: REQUEST_METHOD: POST
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 WARNING [434543]: Warning: error parsing post data as XML: at line 1, column 1: error occurred while parsing element. Assuming urlencoded query string sent in the post body.
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: EXPRESSIONS:{"descricao":"CASE  \r\nWHEN \"natureza\"  = '3101' THEN 'Inc\u00eandio Florestal' \r\nWHEN \"natureza\"  = '3103' THEN 'Inc\u00eandio Mato'  \r\nWHEN \"natureza\"  = '3105' THEN 'Inc\u00eandio Agr\u00edcola' \r\nWHEN \"natureza\"  = '3301' THEN 'Queda de \u00c1rvore'\r\nWHEN \"natureza\"  = '3311' THEN 'Queda Elementos de Constru\u00e7\u00e3o'\r\nWHEN \"natureza\"  = '3313' THEN 'Movimento de Massa'\r\nWHEN \"natureza\"  = '3315' THEN 'Inunda\u00e7\u00e3o por precipita\u00e7\u00e3o intensa'\r\nWHEN \"natureza\"  = '3329' THEN 'Queda de Estrutura'\r\nWHEN \"natureza\"  = '9101' THEN 'Queda de Neve'\r\nEND"}
10:09:39 INFO Server[434543]: LAYER:ocorrencias_cdos
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:Evaluate
10:09:39 INFO Server[434543]: SERVICE:EXPRESSION
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user login in request headers
10:09:39 INFO Lizmap[434543]: Sending JSON response : {'status': 'success', 'results': [{'descricao': None}], 'errors': [{'descricao': "No feature available for field 'natureza' evaluation"}], 'features': 0}
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 1 ms
10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap_web_client%2Flizmap%2Finstall%2Fma%2FeventosExtremos.qgs
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi?service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING: service=LIZMAP&request=GetServerSettings&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: REQUEST_METHOD: GET
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:GetServerSettings
10:09:39 INFO Server[434543]: SERVICE:LIZMAP
10:09:39 WARNING [434543]: Service CADASTRE is not registered
10:09:39 INFO Lizmap[434543]: Sending JSON response : {'qgis': {'version': '3.16.10', 'name': 'Hannover', 'version_int': 31610}, 'gdalogr': {'name': 'GDAL 3.0.4, released 2020/01/28', 'version_int': '3000400'}, 'services': ['WMS', 'WFS', 'WCS', 'WMTS', 'ATLAS', 'EXPRESSION', 'LIZMAP'], 'lizmap': {'name': 'Lizmap', 'version': '3.6.3'}}
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 1 ms
10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap_web_client%2Flizmap%2Finstall%2Fma%2FeventosExtremos.qgs
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi?service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING: service=WMS&request=GetCapabilitiesAtlas&map=%2Fvar%2Fwww%2Fhtml%2Flizmap%5Fweb%5Fclient%2Flizmap%2Finstall%2Fma%2FeventosExtremos%2Eqgs
10:09:39 INFO Server[434543]: REQUEST_METHOD: GET
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:GetCapabilities
10:09:39 INFO Server[434543]: SERVICE:ATLAS
10:09:39 INFO Server[434543]: VERSION:1.0.0
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 0 ms
10:09:39 INFO Server[434543]: ******************** New request ***************
10:09:39 INFO Server[434543]: Request URL: http://127.0.0.1/cgi-bin/qgis_mapserv.fcgi?
10:09:39 INFO Server[434543]: Environment:
10:09:39 INFO Server[434543]: ------------------------------------------------
10:09:39 INFO Server[434543]: SERVER_NAME: 127.0.0.1
10:09:39 INFO Server[434543]: REQUEST_URI: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: SCRIPT_NAME: /cgi-bin/qgis_mapserv.fcgi
10:09:39 INFO Server[434543]: REMOTE_ADDR: 127.0.0.1
10:09:39 INFO Server[434543]: SERVER_PORT: 80
10:09:39 INFO Server[434543]: QUERY_STRING:
10:09:39 INFO Server[434543]: CONTENT_TYPE: application/x-www-form-urlencoded
10:09:39 INFO Server[434543]: REQUEST_METHOD: POST
10:09:39 INFO Server[434543]: HTTP_ACCEPT: */*
10:09:39 INFO Server[434543]: HTTP_USER_AGENT: Lizmap
10:09:39 WARNING [434543]: Warning: error parsing post data as XML: at line 1, column 1: error occurred while parsing element. Assuming urlencoded query string sent in the post body.
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.requestReady
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Server[434543]: FIELDS:gid,gid
10:09:39 INFO Server[434543]: FILTER:intersects($geometry, @current_geometry)
10:09:39 INFO Server[434543]: FORM_FEATURE:{"type":"Feature","geometry":null,"properties":[]}
10:09:39 INFO Server[434543]: LAYER:c_freguesias
10:09:39 INFO Server[434543]: MAP:/var/www/html/lizmap_web_client/lizmap/install/ma/eventosExtremos.qgs
10:09:39 INFO Server[434543]: REQUEST:getFeatureWithFormScope
10:09:39 INFO Server[434543]: SERVICE:EXPRESSION
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user groups in request headers
10:09:39 INFO Lizmap[434543]: Request headers provided
10:09:39 INFO Lizmap[434543]: No lizmap user login in request headers
10:09:39 INFO WfsOutputExtension[434543]: WfsOutputExtension.responseComplete
10:09:39 INFO Server[434543]: Request finished in 7 ms
josemvm commented 2 years ago

hi @Gustry is it expected to work with lizmap plugin installed on qgis server (or not) ? thanks

josemvm commented 1 year ago

https://github.com/3liz/lizmap-web-client/issues/3226 the expression for default value doesn't work for existing objects nor for new objects on lwc 3.6(.4)

Gustry commented 1 year ago

It depends of the content of the expression. Expressions not using fields with are within the same form are working, such as dates, @lizmap_user... It's a just a quick answer, I don't know all corner cases, when/where expressions are evaluated (especially when fields are involved)

3liz-bot commented 1 year ago

This issue is missing some feedbacks. 👻 Please have a look to the discussion, thanks. 🦎