Skip to main content

Notifications

Power Apps - Building 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:
  • KimberlyM Profile Picture
    KimberlyM 193 on at
    Re: 2 Patch statements and 1 in an If?

    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"));
  • Verified answer
    Re: 2 Patch statements and 1 in an If?

    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,

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard