Skip to main content

Hi,

 

I have been working on K2 Smartforms for a while and seem to be stuck with configuring a very basic rule.

 

We have two drop-down list controls and the value of the second control is filled based on the selection of the item on the first one. Hence, there are scenarios where the second drop-down list might not have any values in it, in which case, we want to hide the control. Hence, the requirement is , if the drop-down list is empty, hide it.

 

I am unable to find a way that calculates the count of items of the drop-down list or a way to evaluate if the drop-down list is empty.

 

Have tried using the below but none has worked:

1. An advanced condition where the control is empty

2. A normal condition where a control does not contain a value.

3. List Count function under List Aggregators

 

Could someone please help identify how this can be achieved?

 

Kind Regards,

Puneet

Hey,


 


You can always set up a rule saying that "When Drop-Down is Changed" as the Event, "If Drop-Down contains "value"" as the Condition, and "then set the properties of Drop-Down2 control" as the Action.  In the configuring action screen just uncheck Enabled.


Hi JakeCooley,

 

Thanks for the response.

 

The requirement is to check if any item exists in Drop-down control 2, if no then hide it or disable it. 

 

Checking for value only tells if any item from the drop-down control is selected or not, but it does not help if the drop-down control is empty i.e. have no items. All we want to do is if a drop-down control is not having any items in it, disable it.

 

Kind Regards,

Puneet


I believe there is no OOB way to count the items in the drop down list without adding in your own code.


 


You can create a rule that says if the drop down list doesn't contain a value to disable it.


 


Will that work, or is there a particular reason you would like to count the items in the drop down?


 


 


Hi JakeCooley,

 

Thanks for the response. 

 

Ye, it seems that writing custom code is the only option at present (but we will try to change the logic or use a work around to hide/disable it).

 

(Using the rule to check if the control does not contain a value only checks if any item is selected or not).

 

We had to use the item check to hide/disable the control. Another scenario was, when we populate the dropdown list control with the result from a Stored Procedure and if there are no items returned i.e. drop down control has no items then give a message to the user saying 'no item found' etc.

 

Kind Regards,

Puneet


There is nothing like 'ItemCount' for the Drop-Down list. I managed alternative solution :

 

1) Added a data label in the view (Visible false).

2) Executed the smartobject method by itself that is used for populating the drop down list.

3) Assigned any of the returning field value to the data label.

4) Checked that data label for any value in the if block and acted accordingly.


Hi,

 

Here is how I accomplished getting the item count for my radio button list:

 

  1. Add a Data Label to the view, set the data type to Number and the Text to 0
  2. Create an Expression, Data Label + 1
  3. Create a rule, When the View executed Initialize then populate Radio Button List control with data then for ALL items in the Radio button List control, set the properties of the Data Label , text = Expression.

See attached screenshot.

 

-ngreanya


10999iD4EF898DC2E11862.png

I agree with Jake reply

"You can always set up a rule saying that "When Drop-Down is Changed" as the Event, "If Drop-Down contains "value"" as the Condition, and "then set the properties of Drop-Down2 control" as the Action.  In the configuring action screen just uncheck Enabled."

 

Perhaps you can add within the Changed Rule... another condition "If Drop-Down does not contains "value" or is "empty" then basically just hide the control


Reply