expressions in calculated value

17 views
Skip to first unread message

Andrzej Kaczówka

unread,
Sep 27, 2022, 5:57:38 AM9/27/22
to Orbeon Forms
Hi,

I have a problem with expressions in "calculated value".
I have two sections:

First section $cotrol1: there are 4 checkboxes with values: 1,2,10,11 respectively.
Second section $control2: there are 2 checkboxes with values 1 and 2.

When in first section I'll check checkbox 3 or 4 (values 10 or 11), I need to check checkbox in $control2 with value 2, in other case uncheck all checkboxes in $control2.
Additionally, in section 2 one checkbox can be checked only.

So, in $control2 in Calculated value I entered:
xxf:split()[1],
if (sum(for $v in xxf:split($control1) return number($v)) > 9) then '1' else ''

First expression makes it impossible to check both checkboxes, second expression is responsible for calculating value from $control1 and check/uncheck checkbox.

In this case I cannot check both checkboxes (it's ok), but second expression doesn't work properly: if is true, checkbox is checked, but in else condition, checkbox is not unchecked.
When I remove "xxf:split()[1]," and there is only if ... else .. expression, then it works ok (but I can check both checkboxes - it's not ok).

The problem is when both expressions are entered. Where is an error?

Thanks for help,
Andrzej


Alessandro Vernet

unread,
Sep 28, 2022, 5:44:09 PM9/28/22
to orb...@googlegroups.com
Hi Andrzej,

Would using an `if` to limit the cases where you fall in the first case to those where you have more than 1  value solve the issue?

if (count(xxf:split()) > 1)
then xxf:split()[1],
else
    if (sum(for $v in xxf:split($control1) return number($v)) > 9)
    then '1' else ''

-Alex

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/10de6522-6a7d-4418-bece-e54b16b7368an%40googlegroups.com.

Andrzej Kaczówka

unread,
Oct 2, 2022, 6:27:35 AM10/2/22
to Orbeon Forms
Hi Alex,

Thanks for help. It's much better but there is still a problem with uncheck the checkbox.
If in the first section $control1 I check 10 or 11, in $control2 checkbox will be checked (it's ok), but if I uncheck it, just checked the checkbox in $control2 still remain checked.
So there is a problem with "else" expression. then '1' works ok (checkbox will be checked) but else '' don't uncheck the checkbox (else '0' not too).
Could you take a look at it?

Thanks,
Andrzej

Alessandro Vernet

unread,
Oct 4, 2022, 12:51:42 AM10/4/22
to orb...@googlegroups.com
Hi Andrzej,

What is the control for the checkbox, exactly? Is it a Single Checkbox? If so, then I'd recommend you use the values "true" and "false". You can also put a Calculated Value field, calculate it based on the checkbox, to check (!) that the value of the checkbox is what you expect. Alternatively, you can also enable the XForms Inspector in your `properties-local.xml`. You'll let me know if this helps.

-Alex

Alessandro Vernet

unread,
Oct 11, 2022, 7:00:52 PM10/11/22
to orb...@googlegroups.com
Hi Andrzej, did you get a chance to check what was going on with the logic, and did you manage to fix it? If not, would you be able to create a minimal example that shows what the problem is?

-Alex
Reply all
Reply to author
Forward
0 new messages