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 / Save collection and re...
Power Apps
Unanswered

Save collection and record the returned ID's

(0) ShareShare
ReportReport
Posted on by 9

Good Morning,
I have a collection which has a temp ID field I am then patching this collection to my SQL table and want to save the returned ID from the new table record in the collection in a different field to my Temp ID so I am left with my collection having both the Temp ID and the True ID.

I was have tryed Update and patch inside a forall and a few other things but I cannot get it to work. 
Is anyone able to assist? 

Categories:
  • eka24 Profile Picture
    20,925 on at

    Do you have a Table with ID and you want to save this Id to the Temp ID of your Collection?

    Do they have a common field

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • MHackney Profile Picture
    9 on at

    The collection is a match for the table fields however currently Im applying a tempID to the ID field of my collection that I am not saving to my table letting it generate a true ID. No other field is uniquely identifiable in my table

    I need to have both the original TempID and the true ID in some form after saving the collection to perform my next actions.
    Ive was trying to have an extra field in my Collection that I inject the ID into but been successful in doing that. 

    My use case is creating a record that I am not committing to my DB tables till its complete and submitted.
    Parent Record (single record data held on controls till submit)
    Child record 1 (CR1) - Repeatable sub form saved to collection till submit when ParentID added <working> 
    Child Record 2 (CR2) - Repeatable sub form of child 1 saved to collection till submit needs to save with CR1 ID

    I can save the CR1 where each record saves with a single ID from the parent without issue, I cant figure out how to save the CR2 records with there corresponding CR1 ID however. 

    I am not sure if I'm being to clear, in another wording - I cant get the last part of the below to work: 

    >Save Parent 

    >For each record CR1 save with the Parents ID
    >For each record CR2 save with the corresponding CR1 ID

    To achieve the last part I was using a TempID to link CR1 to CR2 while the data is held in the collections and trying to on save of CR2 use CR1 TrueID where CR1 TempID matches 



  • v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @MHackney ,

     

    Could you please share some sample codes and snapshots of your app?

    I think I need more information to understand your issue.

     

    Sik

  • MHackney Profile Picture
    9 on at

    Ive thrown together a simplified example :

    MHackney_0-1594802233651.png

     


    Save Case code: 

    Set(CaseID, Patch(
     '[dbo].[CASETABLE]', Defaults('[dbo].[CASETABLE]'),
     {
     CaseName: CaseName.Text
     ,CaseType:CaseType.Type
     }).ID)
    ; ForAll(Issues, Patch('[dbo].[ISSUESTABLE]', Defaults('[dbo].[ISSUESTABLE]'),
     {Case: CaseID
     ,Name: ThisRecord.IssueName
     ,Type: ThisRecord.IssueType})
    ; ForAll(Evidence, Patch('[dbo].[EVIDENCETABLE]', Defaults('[dbo].[EVIDENCETABLE]'),
     {Issue: <IssueID>,
     Name: ThisRecord.EvidenceName
     Type: ThieRecord.EvidenceType})

     

    Its how I feed the IssueID generated on the save of an issue into the evidence I cant figure out.

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 320

#3
Mohsin Ali Profile Picture

Mohsin Ali 246

Last 30 days Overall leaderboard