This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice. This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
The advanced conditions 'Is Empty' and 'Is Not Empty' does not work as expected on a data label with type Number. It always returns is NOT empty regardless of whether a datalabel contains a value or not. We expect the condition to return the correct information.
Before You Begin
This is expected behavior because a numeric value of blank will always be zero. In other words, the number data type has the default value of zero (0) hard-coded.
In order to recreate this scenario, please follow these steps:
1. Create a new view.
2. Place a data label on the View, and give it a name: "dlNumberValue". Make sure the type is Number and give it a default value by typing in a number in the text field.
3. Place another datalabel on the View, and give it the name "dlTextValue". Make sure the type is Text and give it a default value by typing in a bit of text in the text field.
4. Add a button (Transfer empty). On this button, configure a rule that has a 'Transfer data' where you only select the checkboxes in front of the dlNumberValue and dlTextValue. This will effectively clear the two controls, or at least make them empty.
5. Add two buttons and give them the same logic - the one button for dlTextValue and the other button for dlNumberValue. The logic should be two advanced conditions that both show a message box if they are true. In the one advanced condition you check the datalabel for Is Empty, in the other you check for Is Not Empty.
It should eventually look like this:
When button is clicked
If advanced condition is true // in this one, you check if the datalabel is empty
Show message box
If advanced condition is true // in this one you check if the datalabel is NOT empty
6. Run the form. Click the two validate buttons, and you will notice (because of the default value) that both will show the message box for the Is NOT empty logic.
7. Now click the transfer button, and change the data labels to empty, then click the validate buttons again. The button for the text datalabel will show the Is empty error, while the one for the number doesn't show anything at all.
As mentioned before, this is expected behavior because a numeric value of blank will always be zero. In other words, the number data type has the default value of zero (0) hard-coded.
However, there is a workaround you can follow.
On the Advance condition for Number use the Mapping (Text) as the condition validator.
Controls -> dlNumber -> Detail -> Text
Thus when Transferring Empty values to the number field where the Condition is set to 'Is Empty,' this will validate to true. If Number is populated, the Condition will validate to false, also doing vice versa on the 'Is not Empty" to also use the same Control's Text property.