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 / Error: The function 'I...
Power Apps
Answered

Error: The function 'If' has some invalid arguments. Location: DisplayMode

(0) ShareShare
ReportReport
Posted on by 116

Hello,

 

I am new to Power Apps and have created a Purchase Request (PR) form that includes a gallery for each line item of the PR, by following some instructional videos by Shane Young.
The datasource for the gallery is a SharePoint list.
Everything is working and I'm in the process tweaking the form so some buttons are only visible when I want them to be.

 

To start, I have added 'ShowSaveButtons: true'  into the PRCollection.

NewForm(CreateForm);ClearCollect(PRCollection, {LineItem: "", ServiceProductDescription: "", WebURL: "", Qty: "", UOM: "", Price: 0, Subtotal: 0, ShowSaveButtons: true});Navigate(NewItem,ScreenTransition.Cover)

 

 

My GalleryPRCollection includes a SaveIcon and DeleteIcon.

 

Visible property for SaveIcon (note I tried to enter ShowSaveButtons but only ThisItem.ShowSaveButtons was valid))

ThisItem.ShowSaveButtons

 

 

Visible property for DeleteIcon:

SaveIcon.Visible

 

 

Then for each Input field in the gallery I try to enter the following formula but it comes up with the error: The function 'If' has some invalid arguments.

If(ThisItem.ShowSaveButtons, DisplayMode.Edit, View)

 

 

I'm not sure what I'm doing wrong and hope someone has some insight.

Categories:
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,975 Super User 2026 Season 2 on at

    Hi @JayneButton 

     

    1. Try changing 

    If(ThisItem.ShowSaveButtons, DisplayMode.Edit, View)
    to
    If(ThisItem.ShowSaveButtons, DisplayMode.Edit, DisplayMode.View)

     

    2. Can you verify that ShowSaveButtons is seen as a boolean  and not blank / empty (but I assuming its #1)

    3. The context is bad ThisItem. , since this means the selected item in the gallery, just want to make sure its in the actual gallery.


    If you like my answer, I would really appreciate if you please Mark it as Resolved, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey 

  • JayneButton Profile Picture
    116 on at

    Thanks very much Michael. That worked like a charm 🙂

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard