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 / ForAll patch missing r...
Power Apps
Answered

ForAll patch missing records

(0) ShareShare
ReportReport
Posted on by 44

Trying to patch all items in a Collection into a Postgres dB. Using the following code:

 

ForAll(colQsToPostgres, Patch('im_e2e_instance.intervention_question_map', Defaults('im_e2e_instance.intervention_question_map'), {comp_id: comp_id, question_id: question_id, intervention_question_id: intervention_question_id,date_created:Now(),order_position: order_position,survey_version:1}));

 

This seems to work most of the time, but every now and then, it stops working and only uploads part of the records in a collection.

 

For example if the collection has 15 items it will only upload 1 or 2.

After a few hours or after a day or 2 it starts working again.

 

I have no idea what on earth is happening. Any help would be greatly appreciated.

Categories:
  • Verified answer
    EddieE Profile Picture
    4,650 Moderator on at

    @Jargonaut 

    Seems odd indeed. Things you could try (which are faster):

     

    Patch( ForAll()), eg 

     

    Patch('im_e2e_instance.intervention_question_map',
    	ForAll(
    		colQsToPostgres, 
    		{
    			comp_id: comp_id, 
    			question_id: question_id, 
    			intervention_question_id: intervention_question_id,
    			date_created: Now(),
    			order_position: order_position,
    			survey_version: 1
    		}
    	)
    );

     

    or

     

    using Collect()

    Collect( 'im_e2e_instance.intervention_question_map', colQsToPostgres)

    For Collect to work, the collection needs to have the same schema as the table you are sending data to. An easy way to achieve this is to collect one record into the collection first, then clear the collection and continue to use this collection with your current code, eg

    // App OnStart
    // create schema
    ClearCollect( colQsToPostgres, First( 'im_e2e_instance.intervention_question_map' ) );
    
    // clear collection, and it's now ready to be used
    Clear( colQsToPostgres )

     

     

  • Jargonaut Profile Picture
    44 on at

    @EddieE  could I force the schema with a "Showcolumns"? or is your example the best way to go?:

  • Verified answer
    EddieE Profile Picture
    4,650 Moderator on at

    @Jargonaut 

    Yes you could but you'd need to show all columns, so kinda redundant. 

     

    If you want to use / have to use ShowColumns then avoid the Collect() option and try the Patch( ForAll()) method. You could try using the Collect with the ShowColumns but, from memory, I don't think it works correctly ... I could be wrong though as I haven't tried in awhile.

  • Jargonaut Profile Picture
    44 on at

    I'm going to go with the Patch(ForAll()) first then. it's probably already a good improvement from the previous code. See if the issue happens again in a month's time or so. Thank you

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 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard