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

Notifications

Announcements

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:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,392 Super User 2025 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard