You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2022-09-12 14:08:01

WebGreg
Member
Registered: 2020-02-27
Posts: 728

FormCreator - extensive conditions

Hi.

I'm trying to set the new forms in the GLPI version 10.0.3-dev. But I don't know how to set more extensive conditions.

Example...

Question1: Select a device
1. pendrive.
2. printer.
3. computer.

Question2: What problem?
1. Paper is jammed.
2. It doesn't start.

Question3: Has the problem been resolved?
1. Yes
2. No

Question4: Give me the inventory number of the device


And now... I do not want Question4 to be displayed if the user selected:
pendrive - because there is no inventory number

But if he also selects a printer or a computer - this question should appear, because these devices have an inventory number.

Question4 should not appear sooner than after answering Question3.

But Question3 will not always appear - for example, if someone replies to Question2 that it is a paper jam - it makes no sense to ask if the problem has been solved.


This means Question4 cannot be displayed when only the pendrive is selected. It must display when something other than the pendrive is also selected. Since there are many questions, the easiest way is to connect it with the answer to Question3 (no), but because it does not always show up - also when the user, for example, selects "Paper is jammed" as an answer to Question2.

Last edited by WebGreg (2022-09-12 14:08:46)


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#2 2022-09-13 08:19:13

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: FormCreator - extensive conditions

Hi

Try the following condition for question 4
Hide except if
Question 3 = computer
OR question 3 = printer


Warning; the values are case sensitive ! Make sure you type exactly as the values of your checkboxes value (I guess Question 3 is a group of checkboxes)


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#3 2022-09-13 09:02:02

WebGreg
Member
Registered: 2020-02-27
Posts: 728

Re: FormCreator - extensive conditions

Hello btry.

Thank you for your response. I am more concerned with understanding how it works.

a) AND  Q1  =1
b) AND  Q2  =1
c) OR    Q1  =1
d) AND  Q2  =2

What will actually be done here? There are two conditions a+b or c+d? Or only one where it must be selected simultaneously a, b, d while c - it can be checked, but it doesn't have to be met?

I also often rely on the "if it's not empty" condition, but here I also have a problem because I don't know how to actually mean it. Sometimes it works as ">     " and sometimes as "=/=    ".

I wanted to try with regular expressions but can't find any nice examples of how to build them.



Sorry for my English. In this thread I have a huge problem to explain what I mean smile


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#4 2022-09-13 09:05:35

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: FormCreator - extensive conditions

Formcreator handles operator precedence. AND  takes priority over OR

this means that a AND b OR c is evaluated like (a AND b) OR c.

Unfortunately, there is not support for parentheses for now, then in some cases you may need to develop (de-factorize) an expression.

EDIT: the above example for priority is not very good. It is better to consider the following example : a OR b AND c is equivalent to a OR (b AND c)


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#5 2022-09-13 09:30:41

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: FormCreator - extensive conditions

Maybe you need also clarification about evaluating question which allows several values like checkboxes and multiselect. A condition which evaluates them is true when one selected value matches the value of the condition

If you have a checkboxes question with available values a, b,c and d and the user ticks a and c, then the following conditions are true
question = a
question = c

In the opposite, the following conditions are false
question = b
question = d

You should maybe create a test form with 2 questions an play a bit with the conditions.


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#6 2022-09-13 13:22:57

WebGreg
Member
Registered: 2020-02-27
Posts: 728

Re: FormCreator - extensive conditions

Yes, I try all the time smile

Now I created Multiselect:

a
b
c
d
e
f
g

And Select:

yes
no

Question3 I set as hidden unless:

AND; Q2 = yes
AND; Q1 = a
AND; Q1 = c
AND; Q1 = e

It is simple - all items in the list must be selected. But Q3 should show up if: 
Q2=yes and Q1=a
Q2=yes and Q1=c
Q2=yes and Q1=e
Q2=yes and Q1=a and Q1=c
Q2=yes and Q1=a and Q1=e
Q2=yes and Q1=c and Q1=e
Q2=yes and Q1=a and Q1=c and Q1=e


It looks like I have to set it like this:

AND; Q2 = yes
AND; Q1 = a
OR; Q2 = yes
AND; Q1 = c
OR; Q2 = yes
AND; Q1 = e
OR; Q2 = yes
AND; Q1 = a AND; Q1 = c
OR; Q2 = yes
AND; Q1 = a AND; Q1 = e
OR; Q2 = yes
AND; Q1 = c AND; Q1 = e
OR; Q2 = yes
AND; Q1 = a AND; Q1 = c AND; Q1 = e

It's scary because if I now add just 2 elements more...:

Q2=yes and Q1=a                                              OR
Q2=yes and Q1=b                                              OR
Q2=yes and Q1=c                                              OR
Q2=yes and Q1=d                                              OR
Q2=yes and Q1=e                                              OR
Q2=yes and Q1=a and Q1=b                              OR
Q2=yes and Q1=a and Q1=c                              OR
Q2=yes and Q1=a and Q1=d                              OR
Q2=yes and Q1=a and Q1=e                              OR
Q2=yes and Q1=b and Q1=c                              OR
Q2=yes and Q1=b and Q1=d                              OR
Q2=yes and Q1=b and Q1=e                              OR
Q2=yes and Q1=c and Q1=d                              OR
Q2=yes and Q1=c and Q1=e                              OR
Q2=yes and Q1=d and Q1=e                              OR
Q2=yes and Q1=a and Q1=b and Q1=c               OR
Q2=yes and Q1=a and Q1=b and Q1=d               OR
Q2=yes and Q1=a and Q1=b and Q1=e               OR
Q2=yes and Q1=a and Q1=c and Q1=d               OR
Q2=yes and Q1=a and Q1=c and Q1=e               OR
Q2=yes and Q1=a and Q1=d and Q1=e               OR
Q2=yes and Q1=a and Q1=b and Q1=c and Q1=d  OR
Q2=yes and Q1=a and Q1=b and Q1=c and Q1=e  OR
Q2=yes and Q1=a and Q1=b and Q1=c and Q1=d and Q1=e


Missed something? smile

Last edited by WebGreg (2022-09-13 13:37:58)


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

#7 2022-09-14 10:12:43

btry
Moderator
Registered: 2015-10-01
Posts: 593

Re: FormCreator - extensive conditions

Hi

As I said, Formcreator does not supports parentheses in condition expression. Therefore you cannot factorize it and it may grow quickly. This is an improvement to do, but not in the roadmap yet. A sponsor could speedup this task.


No support with MP - Always run an upgrade task on a testing instance before running it on production! Always backup before any upgrade task!

Offline

#8 2022-09-14 19:16:26

WebGreg
Member
Registered: 2020-02-27
Posts: 728

Re: FormCreator - extensive conditions

Thank you btry. Also for the answer here: https://github.com/pluginsGLPI/formcreator/issues/2825 smile


--
GLPI 10.0.7
GLPI-Inventory 1.2.1
Ubuntu Server 20.04 LTS

Offline

Board footer

Powered by FluxBB