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 / Collect, ShowColumns a...
Power Apps
Unanswered

Collect, ShowColumns and Patch - Oh My!

(0) ShareShare
ReportReport
Posted on by 103

I am writing data from a PowerApp to Azure SQL via the SQL connector. The SQL DB (MyDB) has a Table (MyTable) which has columns A, B, C and D. Column A is the primary key and is set for auto-increment. All four columns are set for Not Null values.

 

I want my collection (col_Mine) in my PowerApp only to contain columns and values for columns A and C.

 

What I think/wish should happen is this:

 

Collect(col_Mine,ShowColumns(Patch('dbo.MyTable',Defaults('dbo.MyTable),{B:1,C:2,D:3}),"A","C")) but it doesnt like that. 

 

To make this work now I end up setting a context variable for the entire patch command and then use a separate statement to collect the specific columns from the context variable into the collection.


UpdateContext({cv_temp_Record:Patch('dbo.MyTable',Defaults('dbo.MyTable),{B:1,C:2,D:3})});
Collect(col_Mine,ShowColumns(cv_temp_Record,"A","C"))

 

Does anyone know of a method to accomplish this in one step like my pseudo-code example above?

 

Thanks,

 

Brian

 

Categories:
I have the same question (0)
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    You could also do the same thing using the With() which would wrap it all in one step.

     

    With(
     {_record:Patch('dbo.MyTable',Defaults('dbo.MyTable),{B:1,C:2,D:3})},
     Collect(col_Mine,ShowColumns(_record,"A","C"))
    )

     

  • BrianCCampbell Profile Picture
    103 on at

    Thanks, @Jeff_Thorpe for the suggestion. I am in the throws of trying to get a complex new/edit "non-PowerApp form" form (a multi-screen PowerApp that functions as a form) and am having problems trying to make it all work without having all the screens do direct DB calls every time something on a screen "onChange"s. In effect I have a local collection copy of each "form's" values and the combo patch and collect is trying to keep them in-synch. I was trying to take performance and app size into consideration and not just collect all the 15 other columns of every patch I do into the collection as this "form" has about 20 different tables and from most, I am working with 2 or 3 columns. 

     

    Thanks,

     

    Brian

     

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 493 Most Valuable Professional

#2
11manish Profile Picture

11manish 479

#3
Haque Profile Picture

Haque 328

Last 30 days Overall leaderboard