Hi guys,
I am trying to check if records already exist in datasource. If they do i just want to update them with the same values/modified values. If they don't exist i want to patch them to the datasource.
This is how i check if the records do exist in datasource by a filter:
Set(
varRecord,
Filter(
'Custom Entity [dbo].[PostcodeRange]s',
MakelaarId in colEditMakelaarsToAdd.MakelaarIdNew && PostcodeStart = postcodeStart
)
)
This is my code and commented with 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
)
),
//if the records exist, patch them with the same records or update the values that did change (order could 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 yet patch the record
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