sathyapriyan
Returning Observer

Rule to fill an Input Text field based on value form toggle

Hello Everyone,

I have a toggle and based on the value of the toggle, I want to fill the text box when onlock.

The Below rule fills the field and I want to fill the field only when the toggle is set to yes.

<RULE when="ONLOCK">

<WITH>

<TEXT>Mail to link will be filled at runtime.</TEXT>

</WITH>

<DO>

<PROPERTY name="VALUE" source="lt_text"/>

</DO>

</RULE>

Could you please help me to modify the rule accordingly.

Thanks and Best Regards,

Sathya

0 Kudos
3 Replies
felix_reinhold
Returning Responder

Hi Sathya,

since this seems to be an information for the editor and not a fallback-value for the textfield you shoud consider creating a CMS_LABEL with the text "Mail to link will be filled at runtime." and hide show label and textfield according to the toggle-value

<RULE>

     <WITH>

          <PROPERTY name="value" source="lt_your_toggle" />

     </WITH>

     <DO>

          <PROPERTY name="VISIBLE" source="lt_text"/>

          <NOT>

               <PROPERTY name="VISIBLE" source="lt_your_label"/>

          <NOT>

     </DO>

</RULE>

Best regards

Felix

0 Kudos

Hi Felix,

Thanks for answering my question. But, I want to display the Link Text in the RTE as a hint for the editor. Is there a possibility for it?

Best Regards,

Sathya

0 Kudos

Dear Sathya,

you could use an <IF> within your rule - but this would result in filling the textfield, if the toggle is set, but it wouldn't clear the field, if the toggle is unset.

The solution from Felix doesn't have this limitation, but you won't see the hint within the CMS_INPUT_DOM component, when the link is used within it.

So you need two rules with IF statements.

Furthermore you defined, that your rule should only be executed ONLOCK. In this case the rule won't be fired, if the toggle is changed. I don't think, that is what you want.

I would solve the request with these two rules:

<RULES>

  <RULE>

    <IF>

      <PROPERTY name="VALUE" source="lt_toggle"/>

    </IF>

    <WITH>

      <TEXT>Mail to link will be filled at runtime.</TEXT>

    </WITH>

    <DO>

      <PROPERTY name="VALUE" source="lt_text"/>

    </DO>

  </RULE>

  <RULE>

    <IF>

      <AND>

        <NOT>

          <PROPERTY name="VALUE" source="lt_toggle"/>

        </NOT>

        <OR>

          <PROPERTY name="EMPTY" source="lt_text"/>

          <EQUAL>

            <PROPERTY name="VALUE" source="lt_text"/>

            <TEXT>Mail to link will be filled at runtime.</TEXT>

          </EQUAL>

        </OR>

      </AND>

    </IF>

    <WITH>

      <TEXT>This text has to be overwritten</TEXT>

    </WITH>

    <DO>

      <PROPERTY name="VALUE" source="lt_text"/>

    </DO>

  </RULE>

</RULES>

Explanation: The rules are fired at all changes (missing "when" option)

If the toggle is set, the text "Mail to link will be filled at runtime." is set for the textfield. If it is unset and the text within the textfield is the default text, it will be changed to "This text has to be overwritten".

BUT two conflicting IF statements can cause them to interfere with each other. So it can happen that sometimes the rules cancel each other and nothing happens.

That's why I usually recommend not to do something like that (and would recommend the solution of Felix). But in this case, from a functional point of view, the possible effects should not make things worse.

best regards,

Holger

0 Kudos