
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:
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()}
)
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.
The collection doesn't seem to be bringing in all the information, only some:
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.
What am I missing?
Thanks!
Doug