Jul 13 2023 03:19 PM - edited Jul 13 2023 03:20 PM
I have a Power Apps Canvas app with a tab-like experience developed. The tabs are created from a gallery of buttons. There are fields on each tab.
If a tab is selected, the tab fill should be blue.
Else if the tab is not selected and a specific field on tab 2 (DataCardValue14) has a value, the tab fill should be green to show the field has a value. Else if the tab is not selected and the specific field (DataCardValue14) does NOT have a value, the tab fill should be grey.
The idea is to provide an easy way for users to know if a given tab has an entry for the field or not by seeing the tab color is green, without having to go check it on each tab. Once this works I will add additional fields so the user will know by color if the tab has all the fields entered or not. But for now I am focused on the color fill for one field.
See the screenshot.
The issue:
The code I have written below will:
1] Successfully set the tab fill to blue if the tab is selected
2] Issue here: If the tab is not selected, PA sets the fill to green whether or not the DataCardValue14 field has a value. PA always responds as if this field has a value, even if it does not value. The result is the tab fill is always green even in cases where it should be grey (field is blank).
These have all been tried independently in the Gallery Fill property and all show the same issue.
RGBA(0, 120, 212, 1) is the blue color for a selected tab. I have excluded the code that sets the color on a specific tab for clarity. At this point I just need the code below to accurately see if the DatacardValue is blank or not.
I have tried this with other fields, the same issue replicates on any field. The backend is a SharePoint List. DataCardValue14 refers to a single line of text field, and entry is not required.
If(varTabSelected = ThisItem.ID, RGBA(0, 120, 212, 1),If(Not(IsBlank([DataCardValue14])), Color.Green, Color.Gray))
If(varTabSelected = ThisItem.ID, RGBA(0, 120, 212, 1),If(Not(IsBlank([DataCardValue14.Text])), Color.Green, Color.Gray))
If(varTabSelected = ThisItem.ID, RGBA(0, 120, 212, 1),If(Not(IsEmpty([DataCardValue14])), Color.Green, Color.Gray))
If(varTabSelected = ThisItem.ID, RGBA(0, 120, 212, 1),If(Not(IsEmpty([DataCardValue14.Text])), Color.Green, Color.Gray))
Jul 13 2023 03:56 PM
The issue you are experiencing is that the If Not IsBlank function is always returning true even when the DataCardValue is blank. This is because the IsBlank function only checks if the value of the DataCardValue is empty, not if it is visible. In your case, the DataCardValue is visible, but it is empty.
There are a few ways to fix this issue. One way is to use the HasValue function instead of the IsBlank function. The HasValue function will check if the DataCardValue has any value, regardless of whether it is empty or not.
Another way to fix this issue is to use the Visible property of the DataCardValue. If the DataCardValue is visible, but it is empty, then you can set the Visible property to false. This will hide the DataCardValue, and the If Not IsBlank function will no longer return true.
Here is an example of how to fix this issue using the HasValue function:
If HasValue(DataCardValue1) Then // Do something Else // Do something else End If
Here is an example of how to fix this issue using the Visible property:
If DataCardValue1.Visible Then // Do something Else // Do something else End If
I hope this helps.
Jul 14 2023 08:40 AM - edited Jul 14 2023 08:41 AM
Very Appreciated for your help. Both of your solutions were not successful.
1. HasValue() is not a known function in MS PowerApps. It looks like it is related to checking whether a Media data type field in a record has been initialized with a media object and that the object exists - for Dynamics NAV.
2. Whether the field is visible or not: What causes certain fields to only show when a given tab is selected is the Visible property. This is what makes the tabbed form work as a tabbed form. Normally I set the Visible Property to:
varTabSelected=2
So that it only shows when tab 2 is selected.
In response to your suggestion,
I can't set the Visible Property to false if the field is blank because I have no working function to know of the field is blank - that's my issue, ,Not(isBlank is always returning true, and I need the Visible Property to show the field only if the associated tab is selected, whether or not the field is blank.
However, to test if the visible property is having an effect or causing this issue, I set the Visible property to true so the field always shows regardless of which tab is selected. In this scenario, the issue persists.
Jul 14 2023 08:46 AM
Jul 14 2023 10:35 AM
SolutionSep 03 2024 03:33 AM
Try this
If(DataCardValue1.Selected.Value=Blank(),1,2)
So, in this case, the If statement is checking if the selected value in DataCardValue1 is empty. If it is empty, the function will return 1. Otherwise, if the selected value is not empty, it will return 2.
This function can be used to perform different actions or calculations based on whether a specific data card value is empty or not.
Jul 14 2023 10:35 AM
Solution