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 / Help with Patching SQL...
Power Apps
Unanswered

Help with Patching SQL table from a collection

(0) ShareShare
ReportReport
Posted on by

Hi all, 

 

I apologise that this is a long post, but hopefully someone can point me in the right direction here. 

 

To try & keep it short, what I am trying to achieve is to use a collection to patch/update an existing record in my SQL table. 

 

When the user selects the arrow on the gallery, the textboxes on the right hand side populate with the corresponding data associated with that selection: 

 

DouglasStamper_0-1650970539259.png

DouglasStamper_1-1650970553297.png

 

When the user selects the arrow, I am setting a variable to hold the items data, but I am also creating a collection to hold the same information - with the idea being that I can hold this data in the background so when a user makes a change to any of the data - a new record is created with the new data whilst the old record is updated in the table, but is marked as 'inactive'. 

 

I am doing this because I want to maintain a history in the table. 

 

The OnSelect property of the select arrow is: 

Set(
 SignalRecord,
 ThisItem
);
ClearCollect(
 colPreviousSignalRecord,
 {Signal_ID: SignalRecord.Signal_ID},
 {Signal_Name: SignalRecord.'Signal Name'},
 {Active: 0},
 {ID: SignalRecord.ID},
 {Is_current: false},
 {Report_Type: SignalRecord.'Report Type'},
 {Spill_Level: SignalRecord.Spill_Level},
 {Spill_Start: SignalRecord.Spill_Start},
 {Total_Volume: SignalRecord.Total_Volume},
 {Volume_SUM: SignalRecord.Volume_Sum},
 {SEPA_point_ID: SignalRecord.'SEPA Point ID'},
 {Date_from: SignalRecord.Date_From},
 {Date_to: SignalRecord.Date_To},
 {Sys_updated_by: currentUser},
 {Sys_updated_date: Today()}
)

 

DouglasStamper_2-1650970773777.png

 

The OnSelect property of the submit button is as follows: 

ForAll(
 colPreviousSignalRecord,
 Patch(
 'FLOWRETURNS.SIGNAL_LKP',
 Defaults('FLOWRETURNS.SIGNAL_LKP'),
 {
 ID: ID,
 Signal_ID: Signal_ID,
 Signal_Name: Signal_Name,
 Active: 0,
 Is_current: false,
 Report_Type: Report_Type,
 Spill_Level: Value(Spill_Level),
 Spill_Start: Spill_Start,
 Total_Volume: Value(Total_Volume),
 Volume_SUM: Value(Volume_SUM),
 SEPA_point_ID: Value(SEPA_point_ID),
 Date_from: Date_from,
 Date_to: Date_to,
 Sys_updated_by: Sys_updated_by,
 Sys_updated_date: Sys_updated_date
 }
 )
);
Patch(
 'FLOWRETURNS.SIGNAL_LKP',
 {
 ID: Value(lblSignalRecordID.Text),
 Signal_ID: txtSignalID.Text,
 Signal_Name: txtSignalName.Text,
 Active: Value(txtActive.Text),
 Is_current: tglIsCurrent.Value,
 Report_Type: txtReportTypeSC.Text,
 Spill_Level: Value(txtSpillLevel.Text),
 Spill_Start: drpSpillStart.Selected.Value,
 Total_Volume: Value(txtVolumeDischargeRequired.Text),
 Volume_SUM: Value(txtCalcFormula.Text),
 SEPA_point_ID: Value(lblSepaPointSC.Text),
 Date_from: dteDateFrom.SelectedDate,
 Date_to: dteDateTo.SelectedDate,
 Sys_inserted_by: currentUser,
 Sys_inserted_date: Today(),
 Sys_updated_by: currentUser,
 Sys_updated_date: Today()
 }
);
Set(
 signalErrors,
 Errors('FLOWRETURNS.SIGNAL_LKP')
);
If(
 // check if there were any errors when the signal reference update was submitted
 First(Errors('FLOWRETURNS.SIGNAL_LKP')).Error <> 8,
 // if true, show any error message
 Notify(
 "Signal Reference update failed",
 NotificationType.Error
 ),
 // else, go to success screen
 Navigate('Signal Reference Update Success Screen');
 
);
Refresh('FLOWRETURNS.SIGNAL_VIEW')

 

The issue I am having is that I get errors that certain fields are required (On the patch with the collection) when I press submit. 

DouglasStamper_5-1650971254038.png

 

 

The collection doesn't seem to be bringing in all the information, only some: 

DouglasStamper_3-1650971010431.png

 

 

Although, when I check the collection code, I can see at the bottom that there is indeed a value, but it doesn't seem to be pulling through to the actual collection. 

 

DouglasStamper_6-1650971291937.png

 

What am I missing?

 

Thanks! 

 

Doug

 

Categories:
I have the same question (0)

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 494

#2
WarrenBelz Profile Picture

WarrenBelz 352 Most Valuable Professional

#3
11manish Profile Picture

11manish 323

Last 30 days Overall leaderboard