Service Dialogs: Conditional Visibility

-Is there a way to make items in a service dialog visible conditionally?
Example: if i have a drop down with “Yes” and “No” as choices. To have a text box be visible only when the dropdown selection is “Yes”

Indeed, you can. You have to make the text field dynamic and activate auto
refresh. Then in the method you call for this field, you can set the dialog
item (in)visible with :

$evm.object[‘visible’] = true|false

To make it conditional, you can test the value of your checkbox :

if $evm.root[‘dialog_option_my_checkbox’] == ‘t’
$evm.object[‘visible’] = true
$evm.object[‘visible’] = false

The checkbox also has to be configured to refresh other fields.

However, you will experience overhead when loading the dialog, as the field
will trigger the method. And if you build a complex dialog with many
dynamically visible fields, the overhead will grow.

1 Like


Thanks for your help and your reply. If we can get this working it will be a really big win.
It’s the end of the day here, but I plan on testing this tomorrow.

Thanks again.

Tell me how it goes for you once you’ve run your tests.

I work with midacts, tried out using one dialog element’s output to make another dialog element visible. But not able to get it working.

Started with creating dialog element one with type dynamic dropdown and possible values Yes/No. Then created dialog element two with test field dynamic and checked auto refresh. Declared method as following

$evm.object[‘visible’] = true|false

if $evm.root[‘dialog_element1’] == ‘Yes’
$evm.object[‘visible’] = true
$evm.object[‘visible’] = false

Element one does not have to be dynamic, only to be configured to refresh other fields, as shown one the following picture:

Then element two is a dynamic text field configured to be auto refreshed, as show on the following picture:

The method called by element two is the following:

if $evm.root['dialog_element1'] == 'Yes'
  $evm.object['visible'] = true
  $evm.object['false'] = false

In your method the line $evm.object['visible'] = true|false is useless. It was just to show you the syntax, e.g. that $evm.object['visible'] is a boolean.

The method can also be reduced to:

$evm.object['visible'] = $evm.root['dialog_element1'] == 'Yes'

When the value of element one is Yes, it looks like this:

And when the value is No it looks like this:

Great explaination.
tkopuru had been telling me that we did not have the visibility checkbox on our dropdown options. It looks like we will have to upgrade from version 4.1 to version 4.2?

We will give that a shot and go from there.
THanks for your help on this! (This is an important feature that we are really looking forward to being able to use).

Yes, visibility is a new feature of CloudForms 4.2, so upgrade is the way to go.

We will perform the upgrade and go from there.

Is it easy to do an in place upgrade? or should we stand up a new environment?

The upgrade is pretty straight forward: https://access.

Be careful to logout, then login again, after the yum update. It
reloads the Ruby environment.

If you have more than one appliance, be sure you follow the upgrade order.

If you have overriden code from ManageIQ or RedHat domains, do a code
review as the upgrade resets these domains to the latest version, thus
potentially modifying the behaviour.

Thanks a lot for detailed explanation and confirmation on Upgrade for visibility feature.

Upgraded our Clouforms servers to 4.2 and able to get element visibility work on condition based in web console.

But it doesn’t work as expected in self-service portal. One of our WebUI appliance server seems to be dead recently. Can this be a reason?

Thanks again.

I have seen the same behavior on my instance. I don’t use SSUI, so I never tested it. I have opened an issue:

Thanks for doing that. We are still new to the who process and what to expect.
We are getting closer now though ; )

Could you please help, I created this post: Dynamic form - events trigger
I think your solution can help me. I run Cloudforms Version 5.9.3