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 / Changing Status when f...
Power Apps
Answered

Changing Status when form saved

(0) ShareShare
ReportReport
Posted on by 136

I have an issue I'm trying to work through and any help would be appreciated.

 

I have a situation where only one user can change the status to Confirmed, but other users can come in and update the record after it has been Confirmed. I need to change the status from Confirmed to Pending, if a Confirmed record is updated by any user. 

 

I think I need this on the Save OnSelect before the actual submitform command. I'm trying the unsaved keyword and using that to switch the status, or at least that is what I'm thinking. I can't get anything to work so I'm coming here for advice. Thank you so much. 

 

This is what I am trying right now, but I'm sure I am wrong. I have email notifications and submitform after this, as I want the new status to change first and trigger emails.

If(User().Email<>"email1" Or "email2" & DataCardValue17_1.Selected.Value = "4 - Confirmed",
Patch(
    BIS_CUSTOMER,
    {ID: Gallery7.Selected.ID},
    {Request_x0020_Status:{
        '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        Value:"3 - Pending"
        }
    }
),"");

Categories:
  • WarrenBelz Profile Picture
    156,732 Most Valuable Professional on at

    Hi @chris_young ,

    Try this for a start

    If(
     User().Email<>"email1" && 
     User().Email<> "email2" &&
     DataCardValue17_1.Selected.Value = "4 - Confirmed",
     Patch(
     BIS_CUSTOMER,
     {ID: Gallery7.Selected.ID},
     {
     Request_x0020_Status:{Value:"3 - Pending"}
     }
     )
    );

     

    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.

  • chris_young Profile Picture
    136 on at

    @WarrenBelz 

     

    Thank you for the suggestion. I tried that and it didn't error but it didn't change the status. Here is all my code that I have within the Save OnSelect. I'm trying to switch the status before emails so workflow starts over. I have tried multiple things but I can't get the Status to change but it doesn't error so I'm not sure what I am doing incorrectly. I have tried Odata type also with the same result, probably wrong syntax but same result.

     

    The Status field itself is a choices dropdown. 

     

    If( ( User().Email<>"email1" || User().Email<> "email2" ) && DataCardValue17_1.Selected.Value = "4 - Confirmed", Patch( BIS_CUSTOMER, {ID: Gallery7.Selected.ID}, {Request_x0020_Status:{Value:"3 - Pending"} } ) );
    If(DataCardValue17_1.Selected.Value = "3 - Pending",
    Office365Outlook.SendEmail("email1" & ";" & "email2",
    "BIS Master Data - Customer " & DataCardValue61_1.Text & " Marked Pending",
    "Please review customer - " & DataCardValue61_1.Text & ". This customer has been marked " & DataCardValue17_1.Selected.Value),
    "");
    SubmitForm(Form1);
    UpdateContext({showPopupSave:false}); ScreenTransition.Fade

  • WarrenBelz Profile Picture
    156,732 Most Valuable Professional on at

    Hi @chris_young ,

    You syntax looks correct - just the logic needs to be tested I think.

    If(
     (
     User().Email<>"email1" || User().Email<> "email2" 
     ) && 
     DataCardValue17_1.Selected.Value = "4 - Confirmed", 
     Patch(
     BIS_CUSTOMER, 
     {ID: Gallery7.Selected.ID}, 
     {
     Request_x0020_Status:{Value:"3 - Pending"} 
     }
     )
    );
    If(
     DataCardValue17_1.Selected.Value = "3 - Pending",
     Office365Outlook.SendEmail(
     "email1" & ";" & "email2",
     "BIS Master Data - Customer " & DataCardValue61_1.Text & " Marked Pending",
     "Please review customer - " & DataCardValue61_1.Text & 
     ". This customer has been marked " & DataCardValue17_1.Selected.Value
     ),
     ""
    );
    SubmitForm(Form1);
    UpdateContext({showPopupSave:false}); 
    ScreenTransition.Fade

    Now a bit of debugging - put this on a label when you believe the Patch should happen

    (User().Email<>"email1" || User().Email<> "email2") && 
    DataCardValue17_1.Selected.Value = "4 - Confirmed", 

    Does it show true? If not, the Patch will not initiate (and the email will go).

    Now do this om a button/icon

    ClearCollect(
     colTest,
     Filter(
     BIS_CUSTOMER, 
     ID= Gallery7.Selected.ID
     )
    )

    Now View > Collections - do you see the record you are trying to Patch?

    Also you might try this

    If(
     (
     User().Email<>"email1" || User().Email<> "email2" 
     ) && 
     DataCardValue17_1.Selected.Value = "4 - Confirmed", 
     UpdateIf(
     BIS_CUSTOMER, 
     ID=Gallery7.Selected.ID, 
     {
     Request_x0020_Status:{Value:"3 - Pending"} 
     }
     )
    );

     

    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.

     

  • chris_young Profile Picture
    136 on at

    @WarrenBelz 

    (User().Email<>"email1" || User().Email<> "email2") && 
    DataCardValue17_1.Selected.Value = "4 - Confirmed"

    Yes this does show true on the label

     

    ClearCollect(
     colTest,
     Filter(
     BIS_CUSTOMER, 
     ID= Gallery7.Selected.ID
     )
    )

    Now View > Collections - do you see the record you are trying to Patch?

    Yes I do see the single item I am trying to patch.

     

    The last piece of code does also show true and show up correctly in the collection but doesn't change the choice to  3 - Pending. 

     

    I think I may have to do a different route with this, as we have both spent way too much time on this. I may not allow a submitForm if he user isn't allowed to do 4. That might be easier. 

     

  • chris_young Profile Picture
    136 on at

    @WarrenBelz 

    So I switched directions and I'm trying to do some user email (No AD connection yet) auth. 

    I have created a popup which shows you don't have authorization. 

     

    I know I have something silly but I just can't get this to work. I am looking to the user before submit. 

     

    If(User().Email<>"email1" || User().Email<> "2" && DataCardValue17_1.Selected.Value = "4 - Confirmed", UpdateContext({showPopupConfirm:true}), SubmitForm(Form1));
    If(DataCardValue17_1.Selected.Value = "3 - Pending",
    Office365Outlook.SendEmail("email1" & ";" & "email2",
    "BIS Master Data - Customer " & DataCardValue61_1.Text & " Marked Pending",
    "Please review customer - " & DataCardValue61_1.Text & ". This customer has been marked " & DataCardValue17_1.Selected.Value),
    "");
    UpdateContext({showPopupSave:false});
    ScreenTransition.Fade

  • WarrenBelz Profile Picture
    156,732 Most Valuable Professional on at

    Hi @chris_young ,

    There is something wrong here - you are saying that this code

    If(
     (
     User().Email<>"email1" || User().Email<> "email2" 
     ) && 
     DataCardValue17_1.Selected.Value = "4 - Confirmed", 
     UpdateIf(
     BIS_CUSTOMER, 
     ID=Gallery7.Selected.ID, 
     {
     Request_x0020_Status:{Value:"3 - Pending"} 
     }
     )
    )

    does not change 'Requested Status' (a Choice Field) in the Table BIS_CUSTOMER to 3 - Pending when the filter is true and the ID is the one selected in the gallery?

     

  • chris_young Profile Picture
    136 on at

    @WarrenBelz 

    yes sir, now it is most likely something that I am doing which I don't know about, but yes it does not change it. 

     

    I'll happily paypal you to screen share and help me figure out what I'm doing. 

  • Verified answer
    WarrenBelz Profile Picture
    156,732 Most Valuable Professional on at

    Hi @chris_young ,

    This is not necessary - just requires some deeper debugging. Get the ID of the item you want to change (I will call it 50) then do this

    Patch(
     BIS_CUSTOMER, 
     {ID:50}, 
     {
     Request_x0020_Status:{Value:"3 - Pending"} 
     }
    )

    does that change the value? If so change it back and add this

    Patch(
     BIS_CUSTOMER, 
     {ID:Gallery7.Selected.ID}, 
     {
     Request_x0020_Status:{Value:"3 - Pending"} 
     }
    )

    does that work? If so, add the If statements one at a time - there has to be something missing.

     

    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.

  • chris_young Profile Picture
    136 on at

    @WarrenBelz 

     

    That works!!! It will patch that record so that's amazing. It was the submitform. I guess it was still processing and that submitform interrupted the request and it wasn't able to complete to the database. I will need to find a way to delay the rest of the Save "ifs" as it needs to change to 3 to enable the new value and emails to be sent out, but it will change it now. Thank you. 

  • WarrenBelz Profile Picture
    156,732 Most Valuable Professional on at

    No problems @chris_young , sometimes you need to pull things apart and keep building them back until you find the broken bit.

    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.

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard