web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help If function in Di...
Power Apps
Answered

Help If function in DisplayMode

(0) ShareShare
ReportReport
Posted on by 81

Hello Community,

 

I want a button to be enabled only when 3 conditions is met:

  • Date Picker - Date picked must not be before today's date
  • Text Input - There must be words
  • Input Pen - Must have scribble

Below is my code

In the App open form OnSelect:

Set(varRecord2, ThisItem); Set(varShowSignOutForm, true); Set(varPen, PenInput1.Image); Set(MyDate,Today()); Set(varDateError, false); Reset(TextInput2); Reset(PenInput1);

 

Button DisplayMode:

If(Len(TextInput2.Text)=0 || varPen = PenInput1.Image || 'Planned Return Date picker'.SelectedDate<MyDate,DisplayMode.Disabled, DisplayMode.Edit)

 

Here is the outcome:

 

Below button should not be enabled: 

Open1333_0-1695862801868.png

 

Below Button should be enabled:

Open1333_1-1695862801909.png

 

I have tried changing || to && but is still doesn't work.

 

Please help 

Categories:
  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    Hi @Open1333,

     

    You can try something like this on the DisplayMode property of the button:

     

     

    If(And(!IsBlank(TextInput2), BlankImage <> PenInput1.Image, DatePicker2 > Today()), DisplayMode.Edit, DisplayMode.Disabled)

     

     

    Note: BlankImage is a variable I set on the OnVisibility property of the screen. This is similar to how you have done it. 

     

    Set(BlankImage, PenInput1.Image)

     

     

    Please tick Accept as solution if the answer is useful.

    Thanks,

    @AARON_C 

  • Open1333 Profile Picture
    81 on at

    Hi @AARON_C ,

     

    Weird the outcome seems to be the same.

     

    App open form OnSelect:

    Set(varRecord2, ThisItem); Set(varShowSignOutForm, true); Set(varPen, PenInput1.Image); Set(MyDate,Today()); Set(varDateError, false); Reset(TextInput2); Reset(PenInput1); Set(BlankImage, PenInput1.Image);

     

    Borrow Button DisplayMode:

    If(And(!IsBlank(TextInput2), BlankImage <> PenInput1.Image, 'Planned Return Date picker' > Today()), DisplayMode.Edit, DisplayMode.Disabled)

     

    Outcome:

    2023-09-28_10h10_29.png

     

  • Verified answer
    cha_cha Profile Picture
    4,932 Moderator on at

    Hello @Open1333 

     

    Do this:

     

    On the screen or (which ever button you have that leads to that form, add this code)

    Reset(PenInput1);
    UpdateContext({
     LOC_BlankSignature: JSON(PenInput1.Image,JSONFormat.IncludeBinaryData),
     LOC_Signature: JSON(PenInput1.Image,JSONFormat.IncludeBinaryData)
     });

     

    Then on the OnSelect property of the PenInput, Add This:

    UpdateContext({
     LOC_Signature: JSON(PenInput1.Image,JSONFormat.IncludeBinaryData)
     });

     

    Lastly, on your Button's DisplayMode, use this:

    If(LOC_Signature=LOC_BlankSignature,DisplayMode.Disabled,DisplayMode.Edit)

     

  • AARON_C Profile Picture
    2,235 Most Valuable Professional on at

    Hi @Open1333,

     

    This is what I have gotten working on my end. Please check that all your fields match up with the formula in the DisplayMode of the button.

    AARON_C_5-1695868247978.png

     



     

    Only text input and date are filled out: Button disabled

    AARON_C_3-1695867844980.png

     

     

     

    When all fields are filled out but selected date is before todays date: Button disabled

    AARON_C_2-1695867730043.png

     

     

     

     

     

     

    When all conditions are met: Button enabled

    AARON_C_4-1695867922979.png

     

     

    Please tick Accept as solution if the answer is useful.

    Thanks,

    @AARON_C 

  • Open1333 Profile Picture
    81 on at

    Thank you guys! I am new to Powerapps, 

     

    Not sure why on my side comparing JSONFormat Binary number works. 🙂

  • cha_cha Profile Picture
    4,932 Moderator on at

    Hello both @Open1333 @AARON_C 

     

    I have done a couple of test on my end which is why it took time for me to respond and would like to rest my case for this and probably for people who will encounter the same issue in the future.

     

    Using images, after a reset as shown on the code below, the Live PenInput Image will always have a different URL compared the BlankImage. So they will alway be considered not matching. Unlike the JSON Sizing comparison, it shows the same size. On another note, maybe having the Reset and UpdateContext  not executed consecutively would make any differece.

     

    Here's the JSON code btw: 

    "LOC_BlankSignature: " & Len(LOC_BlankSignature) - 814
    
    //Next Label:
    "LOC_Signature: " & Len(LOC_Signature) - 814

    cha_cha_0-1695869822975.png

     

    Then I went on signing and as always, the Live PenInput.image is again different however this would not mean anything as it's been different since the app was loaded.

    cha_cha_1-1695870116875.png

     

    This is why the JSON is probably the better choice when comparing signature image.

    Previous, we can use JSON directly on the DisplayMode property but it looks like it's no longer working now so we had to resort on putting it in a variable in onSelect.

     

    Using JSON in DisplayMode - no longer works now

    https://powerusers.microsoft.com/t5/Building-Power-Apps/How-to-detect-if-the-penInput-is-blank-or-empty/td-p/329751

     

    Using Image - Depends on the order of code execution. Reset probably should be done way way before any setting a variable or context.

    https://powerusers.microsoft.com/t5/Building-Power-Apps/How-do-you-determine-if-Pen-Input-is-blank/td-p/84079

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard