1

I've got the following problem : I have different periods (selected with a drop-down menu, which is like "Paléolithique", "Mésolithique"... etc) and I'd like the fields "Année inf" and "Année sup" to be set to the default values of beginning and of end of each of these periods in my form. However, I can't use the previous fields set in my form (the three following codes for "Année inf" have failed) :

CASE 
WHEN "Période inf" like '%Paléo%' then -15000 
WHEN "Période inf" like '%Epipal%' then -12000 
WHEN "Période inf" like '%Mésol%' then -9500 
WHEN "Période inf" like '%Néolitique ancien%' then -5500
WHEN "Période inf" like '%Néolitique moyen%' then -4800
WHEN "Période inf" like '%Néolitique final%' then -3500
WHEN "Période inf" like '%Bronze%' then -2200
WHEN "Période inf" like '%Hallstatt%' then -800
WHEN "Période inf" like '%La Tène%' then -450
WHEN "Période inf" like '%Antiquité%' then -27
WHEN "Période inf" like '%Moyen%' then 476
WHEN "Période inf" like '%moderne%' then 1492
else 1789
END

CASE 
WHEN current_value('Période inf') like '%Paléo%' then -15000 
WHEN current_value('Période inf') like '%Epipal%' then -12000 
WHEN current_value('Période inf') like '%Mésol%' then -9500 
WHEN current_value('Période inf') like '%Néolitique ancien%' then -5500
WHEN current_value('Période inf') like '%Néolitique moyen%' then -4800
WHEN current_value('Période inf') like '%Néolitique final%' then -3500
WHEN current_value('Période inf') like '%Bronze%' then -2200
WHEN current_value('Période inf') like '%Hallstatt%' then -800
WHEN current_value('Période inf') like '%La Tène%' then -450
WHEN current_value('Période inf') like '%Antiquité%' then -27
WHEN current_value('Période inf') like '%Moyen%' then 476
WHEN current_value('Période inf') like '%moderne%' then 1492
else 1789
END

CASE 
WHEN attribute($current_feature, 'Période inf') like '%Paléo%' then -15000 
WHEN attribute($current_feature, 'Période inf') like '%Epipal%' then -12000 
WHEN attribute($current_feature, 'Période inf') like '%Mésol%' then -9500 
WHEN attribute($current_feature, 'Période inf') like '%Néolitique ancien%' then -5500
WHEN attribute($current_feature, 'Période inf') like '%Néolitique moyen%' then -4800
WHEN attribute($current_feature, 'Période inf') like '%Néolitique final%' then -3500
WHEN attribute($current_feature, 'Période inf') like '%Bronze%' then -2200
WHEN attribute($current_feature, 'Période inf') like '%Hallstatt%' then -800
WHEN attribute($current_feature, 'Période inf') like '%La Tène%' then -450
WHEN attribute($current_feature, 'Période inf') like '%Antiquité%' then -27
WHEN attribute($current_feature, 'Période inf') like '%Moyen%' then 476
WHEN attribute($current_feature, 'Période inf') like '%moderne%' then 1492
else 1789
END

I'm wondering if I must use a python script but I don't know how to do.

  • In witch way did they fail ? did you get any error message ? and witch kind of field are you trying to update – J.R Feb 13 at 10:55
  • Do you want this feature : north-road.com/drill-down-cascading-forms ? – J. Monticolo Feb 13 at 10:55
  • You want to edit the field "Année inf" in the field calculator ? I try the first code and it works. – Vincent Bré Feb 13 at 10:55
  • The test is always false, then the default value is always set to 1789. It's not an update but a default value that I want, when I create my form. The fact is that I succeeded in filter the expression with something like the first code, but when I want to set the default value it is not possible because I can't use other fields. – Paanik Feb 13 at 13:38
  • This feature is made for limiting the choice in drop-down menu depending on a previous field I guess, but I already know how to do it with current_value ... my problem is the default value – Paanik Feb 13 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.