Skip to main content

Dynamic Forms | Compare with a value from the Project Settings

Comments

4 comments

  • Zendesk API User
    Author: hoebbel - 10/24/2023 13:44

    Hello Noura,

    if I understand it correctly, this is about hiding input components when a certain toggle is [un]set in the project settings.
    So a rule should be applied that evaluates values from a completely different form. This is not possible.
    Instead, the value from the other form must be transferred to a [hidden] input component and then evaluated by rule. For the transport of the value the FormDataValueService can be used.
    First: Define a [hidden] Toggle componente within the metadata template
    Second: Define a rule, that uses the FormDataValueService to transport the setting from the project settings to this component.
    Link to Documentation
    Third: use a rule, that evaluates the [local] component to set the visible status of the other components.

    Examples (untested, just as an example how it could look like. Annotation: For testing purposes I recomment not to hide the component, so that you can check, if it is working)
    First:

    <CMS_INPUT_TOGGLE name="md_use_target_groups" hidden="yes" type="radio" hFill="yes" noBreak="yes" preset="default" singleLine="no" useLanguages="yes"> <LANGINFOS> <LANGINFO lang="*" label="Use Targetgroups"/> <LANGINFO lang="DE" label="Zielgruppen nutzen"/> </LANGINFOS> </CMS_INPUT_TOGGLE>

    Second:

    <RULE> <SCHEDULE delay="0" id="use_target_groups" service="FormDataValueService"> <PARAM name="ID"> <PROPERTY name="PROJECT_PROPERTIES_ID" source="#global"/> </PARAM> <PARAM name="STORETYPE"> <TEXT>GLOBALSTORE</TEXT> </PARAM> <PARAM name="FIELD"> <TEXT>ps_use_target_groups</TEXT> </PARAM> <PARAM name="LANGUAGE"> <PROPERTY source="#global" name="LANG"/> </PARAM> </SCHEDULE> <DO> <PROPERTY name="VALUE" source="md_use_target_groups"/> </DO> </RULE>

    Third: your example 1, just adapt the component name to the hidden local component.

    best regards
    Holger

     

    0
  • Zendesk API User
    Author: noura_nouri - 10/25/2023 15:38

    Hello Holger,

    Thank you so much for your time and response.

    I tested our the solution you provided, it doesn't seem to be working. I am assuming that the md_use_target_groups "variable" is not being set correctly, because when I turn its hidden option to "no", it shows no value (neither On nor Off), even when I set it manually nothing changes.

    And I get the following warning in the logs: (de.espirit.firstspirit.forms.rules.NotFact): Cannot compute inverse value of 'null'

    Here's the new code I used:

     

     

    <RULE> <SCHEDULE delay="0" id="use_target_groups" service="FormDataValueService"> <PARAM name="ID"> <PROPERTY name="PROJECT_PROPERTIES_ID" source="#global"/> </PARAM> <PARAM name="STORETYPE"> <TEXT>GLOBALSTORE</TEXT> </PARAM> <PARAM name="FIELD"> <TEXT>ps_use_target_groups</TEXT> </PARAM> <PARAM name="LANGUAGE"> <PROPERTY name="LANG" source="#global"/> </PARAM> </SCHEDULE> <DO> <PROPERTY name="VALUE" source="md_use_target_groups"/> </DO> </RULE> <RULE> <IF> <EQUAL> <PROPERTY name="VALUE" source="md_use_target_groups"/> <FALSE/> </EQUAL> </IF> <DO> <NOT> <PROPERTY name="VISIBLE" source="#form.meta_target_groups"/> </NOT> </DO> </RULE>

     

     


    meta_target_groups being the name of the CMS_GROUP

    I also tried all different variations of the code, namely:
    1. testing if the toggle is equal to True and removing the NOT tags
    2. using the components within that cms_group and setting them to visible/not visible
    3. listing all other cms_groups and setting their visibility
    4. using <WITH> <FALSE/> </WITH> <DO>...</DO> after the IF statement block
    5. with and without #form.
    etc

    Nothing seems to be working, the value of the input toggle doesn't seem to be passed correctly or maybe not read correctly, maybe.

    Do you have any ideas what might be the cause of the problem here?

    Thank you again!
    Best regards,
    Noura

    0
  • Zendesk API User
    Author: noura_nouri - 10/27/2023 12:53

    Hi Holger,

    Thank you so much for your help.
    Removing the language parameter was really helpful.
    The problem is now solved.

    Best regards,
    Noura

    0
  • Zendesk API User
    Author: hoebbel - 10/25/2023 16:54

    Hello Noura,

    I just checked my answer and found the thinking mistake I made.
    We are after all in the metadata - these are language independent. So we can't pass the (not existing) current language to the FormDataValue service to get the data from the project settings page.
    I am very sorry for this carelessness error. So step two has to look like this (same as before but without the language param)

    <RULE> <SCHEDULE delay="0" id="use_target_groups" service="FormDataValueService"> <PARAM name="ID"> <PROPERTY name="PROJECT_PROPERTIES_ID" source="#global"/> </PARAM> <PARAM name="STORETYPE"> <TEXT>GLOBALSTORE</TEXT> </PARAM> <PARAM name="FIELD"> <TEXT>ps_use_target_groups</TEXT> </PARAM> </SCHEDULE> <DO> <PROPERTY name="VALUE" source="md_use_target_groups"/> </DO> </RULE>

     As long as the toogle component within the projects setting page is language independent, that should work. (if it is language dependent, it still may work )

    Does the toogle component now gets the appropriate value from the project property page? 

    Hint: the FormDataValueService only reads stored data. So if you change the value withn the projects property page, you have to save the change!

    Best regards
    Holger

    0

Please sign in to leave a comment.