web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Is it possible to make...
Power Apps
Unanswered

Is it possible to make a Patch function reusable?

(0) ShareShare
ReportReport
Posted on by 277
In a canvas app, I have a patch function which is repeating 5 times in different screen.
 
Patch('dbo.mytable',LookUp('dbo.mytable',ID=varID),
        Switch(varTestID,
        "A",{col1:varCurrentStatus},
        "B",{col2:varCurrentStatus},
        "C",{col3:varCurrentStatus},
        "D",{col4:varCurrentStatus},
        "E",{col5:varCurrentStatus}
        )
    );
 
Recently, we added a new column to dbo.mytable. So we need to update it with a new line:
"F",{col6:varCurrentStatus}
 
But we only updated one screen only. It introduced bug to the App.
 
I wonder is there any way I can create a reusable Patch function so that I can update one single place?
I have the same question (0)
  • Suggested answer
    Ali5 Profile Picture
    10 on at
    Hey, 
     
    For something like this have you considered using a button (Button1) and adding your patch code to that? Yprou can then set Visible on the button to No and then anytime you want to run the patch function instead you write Select(Button1) that will then run your patch function.
     
    For example on a hidden screen you have a Button1 with onSelect property set to:
     
    Patch('dbo.mytable',LookUp('dbo.mytable',ID=varID),
            Switch(varTestID,
            "A",{col1:varCurrentStatus},
            "B",{col2:varCurrentStatus},
            "C",{col3:varCurrentStatus},
            "D",{col4:varCurrentStatus},
            "E",{col5:varCurrentStatus},
            "F",{col6:varCurrentStatus}
            )
        );
     
    Then anytime you want to execute that code on another screen you just run Select(Button1).
     
    Hope that helps!
     
    Asad

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard