Hi guys,
I am trying to check if records inside a collection already exist in my datasource. If they do exist in the datasource i just want to update them with the same values/modified values. If they don't exist i want to patch the new records to the datasource.
This formula below returns me the records inside my collection that already exist in the datasource.
Set(
varRecord,
Filter(
'Custom Entity [dbo].[PostcodeRange]s',
MakelaarId in colEditMakelaarsToAdd.MakelaarIdNew && PostcodeStart = postcodeStart && Order in colEditMakelaarsToAdd.sortnummer
)
)
The formula below explains what i am trying to achieve.
ForAll(
colEditMakelaarsToAdd,
//check if the records from "coleditMakelaarsToAdd" exist in the datasource "Custom Entity [dbo].[PostcodeRange]s"
If(
IsBlank(
LookUp(
'Custom Entity [dbo].[PostcodeRange]s',
MakelaarId in colEditMakelaarsToAdd.MakelaarIdNew && PostcodeStart = postcodeStart && Order in colEditMakelaarsToAdd.sortnummer
)
),
//if the records exist in the datasource, update them with the same values or update the values that did change
Patch(
'Custom Entity [dbo].[PostcodeRange]s',
Defaults('Custom Entity [dbo].[PostcodeRange]s'),
{
MakelaarId: MakelaarIdNew,
Order: sortnummer,
PostcodeEinde: Value(TextInput2_1.Text),
PostcodeStart: Value(TextInput1_1.Text)
}
),
//if the records don't exist in the datasource, patch the new records
Patch(
'Custom Entity [dbo].[PostcodeRange]s',
Defaults('Custom Entity [dbo].[PostcodeRange]s'),
{
MakelaarId: MakelaarIdNew,
Order: sortnummer,
PostcodeEinde: Value(TextInput2_1.Text),
PostcodeStart: Value(TextInput1_1.Text)
}
)
)
);
Best Regards,
Anthony