Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Patching and Opening Incidents in Powerapps

(1) ShareShare
ReportReport
Posted on 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 at
    Re: Patching and Opening Incidents in Powerapps

    Thank  you, this worked!

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 770 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 494

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 399