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 / Get the ID ForAll patc...
Power Apps
Unanswered

Get the ID ForAll patched record

(0) ShareShare
ReportReport
Posted on by 521

Hello All,
Is it possible to get the ID of the newly just submitted for ForAll and I would like if a note added to the record patch to another list called Project History all notes with id's please.

Thank you so much.

ForAll(
 galFlexible.AllItems,
 Patch(
 'Project List',
 Defaults('Project List'),
 {
 Title: txtEditScreen_Title.Text
 

 
 }
 ) 
);
// EXAMPLE OTHER LIST WANTED TO PATCH FORLL NOTE JUST ADDED.

If(
 !IsBlank(txtLineItemsNotes.Text),
 Patch(
 'Project History',
 Defaults('Project History'),
 {
 Title: Now(),
 Comments: Trim(txtLineItemsNotes.Text),
 
 'Project Type': {Value: "Comments"}
 ProjectID: I NEED THE ID'S JUST PATCHED HERE
 }
 )
);

 

Categories:
I have the same question (0)
  • Gochix Profile Picture
    1,935 Moderator on at

    Add a text label to your gallery that will display ID - then try:

     

    ForAll(
     galFlexible.AllItems,
     Patch(
     'Project List',
     Defaults('Project List'),
     {
     Title: txtEditScreen_Title.Text
     
    
     
     }
     );
     Collect(tempcol,txtEditScreen_ID.Text); // Text label with ID
    
    // EXAMPLE OTHER LIST WANTED TO PATCH FORLL NOTE JUST ADDED.
    
    If(
     !IsBlank(txtLineItemsNotes.Text),
     Patch(
     'Project History',
     Defaults('Project History'),
     {
     Title: Now(),
     Comments: Trim(txtLineItemsNotes.Text),
     
     'Project Type': {Value: "Comments"},
     ProjectID: First(tempcol).ID
     }
     )
     Clear(tempcol);
    )
    );

     

     


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • PowerApps11 Profile Picture
    521 on at

    @Gochix 
    This is new record, if I add a label on the gallery and I  referenced ID it will show wrong ID as  its collection.

    The reason needed the ID is to use on the other SharePoint list called project history.

    @v-bofeng-msft 

  • Gochix Profile Picture
    1,935 Moderator on at

    Okay just to completely understand what you need.

    You want to get the last ID number from 'Project List' collection that ForAll just patched?

    If so then :

    ForAll(
     galFlexible.AllItems,
     Patch(
     'Project List',
     Defaults('Project List'),
     {
     Title: txtEditScreen_Title.Text
     
    
     
     }
     ) 
    
    // EXAMPLE OTHER LIST WANTED TO PATCH FORLL NOTE JUST ADDED.
    
    If(
     !IsBlank(txtLineItemsNotes.Text),
     Patch(
     'Project History',
     Defaults('Project History'),
     {
     Title: Now(),
     Comments: Trim(txtLineItemsNotes.Text),
     
     'Project Type': {Value: "Comments"},
     ProjectID: First(Last('Project List'.ID))
     }
     )
    )
    )


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    you can Set a variable to save the new item ID and use it in the seccond patch like this.

    ForAll(
     galFlexible.AllItems,
    	Set(
    		var, // variable
    		Patch(
    			'Project List',
    			Defaults('Project List'),
    			{
    				Title: txtEditScreen_Title.Text
    			}
    		) 
    	);
    	
    // EXAMPLE OTHER LIST WANTED TO PATCH FORLL NOTE JUST ADDED.
    
    	If(
    		!IsBlank(txtLineItemsNotes.Text),
    		Patch(
    			'Project History',
    			Defaults('Project History'),
    			{
    				Title: Now(),
    				Comments: Trim(txtLineItemsNotes.Text),
    				
    				'Project Type': {Value: "Comments"}
    				 ProjectID: var.ID // you will use the variable here
    			}
    		)
    	);
    )

      I put both patches inside the forall because I thought you want save each new item in the history.

  • PowerApps11 Profile Picture
    521 on at

    Tested but not getting the right ID's for the patched record

  • Aapok Profile Picture
    on at

    If I understood your problem correctly, you want all of the ID's you just created with patch, and save them to another list in a single field?

     

    If so, you can try:

     

    Clear(colPatchedIDs);
    ForAll(
     galFlexible.AllItems,
     Collect(colPatchedIDs, Patch(
     'Project List',
     Defaults('Project List'),
     {
     Title: txtEditScreen_Title.Text
     
    
     
     }
     ).ID) 
    );
    // EXAMPLE OTHER LIST WANTED TO PATCH FORLL NOTE JUST ADDED.
    
    If(
     !IsBlank(txtLineItemsNotes.Text),
     Patch(
     'Project History',
     Defaults('Project History'),
     {
     Title: Now(),
     Comments: Trim(txtLineItemsNotes.Text),
     
     'Project Type': {Value: "Comments"}
     ProjectID: Concat(colPatchedIDs, Value & "; ")
     }
     )
    );

    I did a quick test patching another collection with a button, and using a label to display the produced IDs. 

    Since you are creating new items, the produced ID's should be distinct by default. You can also change the separator of the ID's to better suit your needs.

  • PowerApps11 Profile Picture
    521 on at

    Hello @Aapok 
    All I need is when patched ForAll get the ID's just patched and copy those to another SharePoint list for example in the collections I have a field called Comments  and other SharePoint too and save them appropriately to ProjectID and comments just patched ForAll to make it relationship and easier to recall later 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard