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 / 2 Patch statements and...
Power Apps
Answered

2 Patch statements and 1 in an If?

(0) ShareShare
ReportReport
Posted on by 193

My app is designed to track lead status and progress. On my "Edit" Screen I have 2 Forms.
One submits data to my Lead_Data SharePoint list and is data that should not be easily changed so I have it set to view only when the page is loaded.
The other submits data to my Lead_History SharePoint list and is the main form to edit when you come to this page. 
The initial status after the lead is newly created is set to Not Started (this is in my Lead_Data SPL). When the user comes to add a item to the activity tracker area (my Lead_History SPL) I would like it to update the status automatically without having to edit the Lead_Data form to "In Progress". 

The below code is what I have come up with so far (see red text), but doesn't work. The first Patch statement works perfectly and as I expect.  Suggestions on either how my thinking is wrong or how I can correct my thinking? Thanks!

Patch(Lead_History, Defaults(Lead_History), {Title: "", Note: txt_HistoryDetail.Text, HistoryDate: Text( Now(), "[$-en-US]mm/dd/yyyy hh:mm:ss"), LeadID: Gallery_Dashboard.Selected.ID});

If(Gallery_Dashboard.Selected.Status.Value = "Not Started", Patch(Lead_Data, Gallery_Dashboard.Selected, {Status: '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: 0, Value: "In Progress"}));
Categories:
I have the same question (0)
  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @KimberlyM ,

    Could you tell me the data type of Status field?

    If it is a choice data type, try this formula:

    If(Gallery_Dashboard.Selected.Status.Value = "Not Started", 
    Patch(Lead_Data, Gallery_Dashboard.Selected, {Status:{Value:"In Progress"}}));

    If it is a look up field, try this formula:

    If(Gallery_Dashboard.Selected.Status.Value = "Not Started", 
    Patch(Lead_Data, Gallery_Dashboard.Selected, {Status: '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id: Gallery_Dashboard.Selected.ID, Value: "In Progress"}));

     Here's a similar issue about how to update lookup field for your reference:

    https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/How-to-patch-a-SharePoint-Lookup-Column/m-p/24094

     

     

     

    Best regards,

  • KimberlyM Profile Picture
    193 on at

    The Status field that defines what should be loading is a choice field. When I use the code you suggest the button does nothing - it loads nothing, changes nothing. This is either the problem I keep having with this button or that it loads nothing but a blank screen.

    I have even tried to use collections but I can't get these to load either.  

    // Collect Not Started & In Progress :::::: ACTIVE DEALS ::::::
     ClearCollect(colDash_ActiveDeals, Filter(Lead_Data,Status.Value="Not Started"));
     Collect(colDash_ActiveDeals, Filter(Lead_Data,Status.Value="In Progress"));
     Set(varActiveDeals, colDash_ActiveDeals);
    
    // Collect Dead Deals :::::: DEAD DEALS ::::::
     ClearCollect(colDash_DeadDeals, Filter(Lead_Data,Status.Value="Dead Deal"));
    
    // Collect Completed Deals :::::: COMPLETED DEALS ::::::
     ClearCollect(colDash_CompletedDeals, Filter(Lead_Data,Status.Value="Completed Deal"));

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard