Skip to main content

Notifications

Power Apps - Microsoft Dataverse
Suggested answer

Command button function not working on consecutive clicks

(0) ShareShare
ReportReport
Posted on by 113

Hi community

 

With command buttons now in GA as of a few days ago, I'm adding them into a model-driven app build.

 

The command OnSelect runs a fairly simple series of Power Fx commands (If, Notify, Confirm, Patch). The If and Notify functions first do some simple data validation, and the confirm displays a simple confirmation message. Then the patch updates a yes/no 'trigger' column to yes/true and this in turn triggers a flow using a Dataverse row modify trigger at the end of the flow it switches the trigger column back to no/false - ready for next time.

 

All is good when the command is run the first time - everything works perfectly. The Power Fx commands work, 'trigger' column goes to yes and the flow runs with the trigger switched back to no at the end.

 

However, if the command is clicked a second time the Power FX Confirm function works but the Patch isn't updating the 'trigger' column and therefore the flow doesn't run 🤔

 

Now, I've found out a couple of ways to get it to run. If I remove a value from any of the data validation columns (the ones that the If functions check, it displays the notifications. Replacing the values will then run the Power Fx and flow as normal. The other work around is refreshing the browser, this makes the commands and flow work every time. 

 

Now, instead of telling users they need to refresh the browser in between clicks...what can I do? Is there a function to add to the command to 'reset' it and allow it to run again?!

 

Thanks

Matt

  • Suggested answer
    CU16011356-0 Profile Picture
    CU16011356-0 2 on at
    Command button function not working on consecutive clicks
    You can use Refresh(DataSource) function to reset state of Commandbar Button
     
    E.g. For button on Case form use Refresh(Cases).
     
    If(     
        Confirm("This will Perform blah action.",
            {Title: "Execute", ConfirmButton: "Yes", CancelButton: "No"}
        ),    
            Patch(Cases,Self.Selected.Item,{'MyFlag':true});Refresh(Cases),
        false
    )
     
    This should do the trick.

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,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard

Featured topics