Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Patch Statement for Text Field, DropDown and ComboBox

(0) ShareShare
ReportReport
Posted on by

@RandyHayes 

 

Hello,

 

I am struggling with a Patch statement for an editable grid right now. Here is what I currently have on my Save icon. This formula isn't working and I'm not sure how to add the last part of the formula which is for a ComboBox control.

 

Patch('Project List',First(Filter('Project List', ID=ThisItem.ID)),
{'Project Number': TIProjectNumber_1.Text,'Project Name': TIProjectName_1.Text},
Type:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Value:ddPLProjType_1.Selected.Value},
Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Value:ddPSStatus_1.Selected.Value}});

 

Screenshots of my app interface and column types are attached. The names of my controls from left to right are:

TIProjectNumber_1, TIProjectName_1, cbPLProjOwner_1, ddPLProjType_1, ddPSStatus_1

 

In the Patch statement, I made up the names "Type" and "Status". I've watched so many videos on how to put together editable grids and Patch statements at this point that I'm getting a bit confused. I'd appreciate any help Randy or others might have to offer. Let me know if you need any other data points. Thanks!

 

Teresa

Categories:
  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @tagustin2020 

    Excellent!  🙂 Have a nice evening also.

  • tagustin2020 Profile Picture
    on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @RandyHayes 

     

    That was the issue! Everything resolved as soon as I turned on Search. Totally forgot that part so thank you!

     

    Have a nice evening Randy,

    Teresa

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @tagustin2020 

    Is the Allow Searching option turned on?

  • tagustin2020 Profile Picture
    on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @RandyHayes 

     

    Thank you Randy, I removed the formula from the Default property of the combobox. It is now blank. The DefaultSelectedItems property is set to ThisItem.'Project Owner', but I'm still not able to remove my name and replace it with someone else in edit mode. I can click the X next to my name to remove it, but if I try to search for a new name, nothing happens. When I click the Save icon, my name reappears. Is there some other property I need to set?

     

    Teresa

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @tagustin2020 

    Your Items property is good. The problem is you are setting the Default property of the combobox which doesn't do anything.  You need to be setting the DefaultSelectedItems property.  With Comboboxes you must match the schema of the Items records.  IN your case, the Items records are SharePoint User records.  So, you will need to match that.

    If your ThisItem.'Project Owner' is direct from your list, then just set that in the DefaultSelectedItems property.

     

    See if that moves you forward.

     

  • tagustin2020 Profile Picture
    on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @RandyHayes @WarrenBelz 

     

    Thank you Randy and Warren for your prompt responses. The first formula by Randy is working the best so far, but I'm having a couple of issues with the Project Owner field. 

     

    Issue #1: When list is in edit mode, I am not able to delete my name and choose someone else.

    Issue #2: When I processed the Patch statement, my name overwrote all of the Project Owners and now appears in every item in the list.

     

    The Items property for the Project Owner combo box is: Choices([@'Project List'].'Project Owner'). I'm getting an error on the ComboBox Default property: ThisItem.'Project Owner'.DisplayName which I have attached for your review. Can you please help me figure out what I am doing wrong?

     

    Thank you,

    Teresa

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    @tagustin2020 

    Firstly, let's get your formula a little better (using "First(Filter" should be avoided as it is more performant with a Lookup). Also, you have a mistake in it and finally, replace Patch with an UpdateIf - much faster if you have the specific criteria (which you do).  And now, with that "fixed", I will add in the other combobox (with a caveat - addressed later).

    UpdateIf('Project List',
     ID=ThisItem.ID,
     {
     'Project Number': TIProjectNumber_1.Text,
     'Project Name': TIProjectName_1.Text,
     'Project Type': {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Value:ddPLProjType_1.Selected.Value},
     Status:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Value:ddPSStatus_1.Selected.Value},
     'Project Owner': cbPLProjOwner_1.Selected
     }
    );

    The caveat - this assumes that your cbPLProjOwner_1 Items is based on the underlying column, such as with a formula like : Choices([@'Project List'].'Project Owner')

     

    Note as well, if your Project type and Status have an Items property based on Choices, then you don't need all of the extra record information above, it can be shortened to:

    UpdateIf('Project List',
     ID=ThisItem.ID,
     {
     'Project Number': TIProjectNumber_1.Text,
     'Project Name': TIProjectName_1.Text,
     'Project Type': ddPLProjType_1.Selected.Value,
     Status: ddPSStatus_1.Selected.Value,
     'Project Owner': cbPLProjOwner_1.Selected
     }
    );

     

    I hope this is helpful for you.

  • WarrenBelz Profile Picture
    146,658 Most Valuable Professional on at
    Re: Patch Statement for Text Field, DropDown and ComboBox

    Hi @tagustin2020 ,

    Assuming Status is a single choice, you only need this

    Patch(
     'Project List',
     {ID:ThisItem.ID},
     {
     'Project Number': TIProjectNumber_1.Text,
     'Project Name': TIProjectName_1.Text,
     Type:{Value:ddPLProjType_1.Selected.Value},
     Status:{Value:ddPSStatus_1.Selected.Value}
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,658 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard