Skip to main content
Community site session details

Community site session details

Session Id : gvztO7xBkbhDvWvfFN3PsS
Power Apps - Building Power Apps
Answered

Patching and Opening Incidents in Powerapps

Like (1) ShareShare
ReportReport
Posted on 7 Aug 2023 19:40:19 by

Hello,

I'm looking to create an entry in my sharepoint list and then open it using a single button in my app.  The reason being, I want the record and its ID created first, so that no duplicates of the ID will be created.  My thought is to use my OnSelect to Patch Defaults of the ID and status to my Sharepoint list, then the next command in OnSelect would be to open that record, but I'm not sure if that's possible.  Please advise.

 

Thanks.

  • CU06081315-1 Profile Picture
    on 07 Aug 2023 at 20:48:22
    Re: Patching and Opening Incidents in Powerapps

    Thank  you, this worked!

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on 07 Aug 2023 at 20:12:01
    Re: Patching and Opening Incidents in Powerapps

    @cborde3 

    It sounds like you have a good approach in mind.

    You can use the Patch function to create a new entry in your SharePoint list and then immediately navigate to that new entry using the ID that's been assigned. Here's an example formula:

     

    // Create a variable to store the new incident record
    //Set(gloNewIncident, Patch(YourSharePointList, Defaults(YourSharePointList), { Status: "New" }));
    //or
    
    Set(gloNewIncident, Patch(YourSharePointList, { Status: "New" }));
    //primary key ID omitted 2 arg version of Patch, so it has to be { ID: IdOfExistingItem, Status: "New" } to modify existing record. When the ID: IdOfExistingItem part is not included, or the value of ID: is provided as Blank(), then this always creates a new record in 2 arg version of Patch
    
    // Navigate to your detail screen and use Argument #3 to update the varSelectedIncident context variable in the scope of YourDetailScreen
    Navigate(YourDetailScreen, ScreenTransition.None, {varSelectedIncident: gloNewIncident})
    

     

    In this formula example, YourSharePointList should be replaced with the name of your SharePoint list, YourDetailScreen should be replaced with the name of the screen where you want to display the details of the new record, and varSelectedIncident is the name of the context variable you should use on the detail screen to access the new record's details. The third argument of Navigate (optional) is used to provide the context variables to update in the destination screen.

     

    Want to just use the global variable directly instead of use context variables?

     

    Do this 

     

    // Create a variable to store the new incident record
    //Set(gloNewIncident, Patch(YourSharePointList, Defaults(YourSharePointList), { Status: "New" }));
    //or
    
    Set(gloNewIncident, Patch(YourSharePointList, { Status: "New" }));
    //primary key ID omitted 2 arg version of Patch, so it has to be { ID: IdOfExistingItem, Status: "New" } to modify existing record. When the ID: IdOfExistingItem part is not included, or the value of ID: is provided as Blank(), then this always creates a new record in 2 arg version of Patch
    
    // Navigate to your detail screen 
    Navigate(YourDetailScreen, ScreenTransition.None)
    
    //from a property you want use it directly in detail screen such as a Form's Item property, etc.
    gloNewIncident
    

     

    This formula should create a new record in your SharePoint list with the status "New", store that new record in the gloNewIncident global variable, then navigate to YourDetailScreen and have gloNewIncident be updated into context variable varSelectedIncident (if you want to use Navigate's 3rd argument) so that you can display its details using context variable, or just use gloNewIncident directly if you want and omit this third argument from Navigate.

     

    See if it helps @cborde3   

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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete