cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
TCH
Level: Powered On

boolean to string/text

Hi guys, 

I have an app where a button needs to change the display mode, based on whether a LookUp is succesful. I have a label where the text is set to:

LookUp(MedarbejderNR;User().FullName in Navn1;Nr)

 What it does is look in a list if it can find the name of the current user, if it can it returns the users worknumber in the label which is then used when they order items. If it can't find them in the list it returns the boolean value of false. 

However if a user has not been added to the list, they should not be able to order anything and the "order" buttons displaymode should be set to disabled. The issue is that i can't tell the button this, because the "false" that the lookup funtion returns is a boolean value not a text/string. Meaning that if I set the displaymode of the button to: 

If(Label.text = "false",disabled,edit) 

 This won't work as it is not able to compare the data seeing that one is text and one is a boolean. If I do: 

If(label = false,disabled,edit) 

The same problem is relevant. 

Does anyone know a smart solution to this, maybe an alternative method to do this or a way of comparing bollean and string values? 

Thanks 
- Tobi 


8 REPLIES 8
Super User
Super User

Re: boolean to string/text

@TCH

The ISBLANK function is what you'll want to use here.

If(IsBlank(Label.text),Edit,Disabled) 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

TCH
Level: Powered On

Re: boolean to string/text

@mdevaney 

I have tried this, and it does not work, the LookUp function is not returning blank, it is returning false but as a boolean value, so the check for IsBlank will return false whether the LookUp finds data or not 🙂 

Does that make any sense? 🙂 

 

TCH
Level: Powered On

Re: boolean to string/text

@mdevaney  

I can achieve what i want by doing 

If(MedANr.Text=false;Disabled;DisplayMode.Edit)

 So "Forcing" it to compare a boolean value with a string. However when I do this I get a delegation warning, which makes me a bit nervous that its going to crash at some point 🙂  

Super User
Super User

Re: boolean to string/text

@TCH 

My question is "why does the LookUp return false as a text string if it cannot find anything?"  It should simply return a BLANK value.  In my opinion the best way to solve this is to return BLANK instead of false.

 

Once that happens you could use this code to avoid the delegation.  ISBLANK does not current have delegation in SharePoint so we must do this instead of my previous suggestion.

If(MedANr.Text=Blank();Edit;Disabled)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

TCH
Level: Powered On

Re: boolean to string/text

@mdevaney 

This is what I would have thought as well, but PowerApps does not recognise the .text as being blank, but it also does not recognise it as a text value, but if I for example create another label and set the text of this to be "medanr.text" it will return the "string" false, but PowerApps still does not recognise this as text, It does not work when I tell it to disable if the .text = blank or if .text = "false" 🙂 

The problem is that I do not know how to make it return actually blank/nothing instead of false 🙂 

Super User
Super User

Re: boolean to string/text

@TCH 

Something odd is going on in this code. Typically I would not use the IN operator here.

LookUp(MedarbejderNR;User().FullName in Navn1;Nr)

 

Can you try the equals operator instead please?

LookUp(MedarbejderNR;Navn1 = User().FullName;Nr)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

TCH
Level: Powered On

Re: boolean to string/text

@mdevaney 

Yeah I'll agree on that, the equals makes more sense. But it still returns the same, so false if it cannot find an occurence in the list, and the worknumber if it can 🙂 

Super User
Super User

Re: boolean to string/text

@TCH 

I might suggest looking at these threads for some hints on why LookUp is returning false.

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/LookUp-blank-fields-return-false/td...

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/LookUp-blank-fields-return-false/td...

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,061)