cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
mdevaney
Super User
Super User

@Anonymous

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."

Anonymous
Not applicable

@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? 🙂 

 

Anonymous
Not applicable

@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 🙂  

@Anonymous 

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."

Anonymous
Not applicable

@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 🙂 

@Anonymous 

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."

Anonymous
Not applicable

@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 🙂 

@Anonymous 

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-p/213223

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

 

---
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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,688)