I am first checking if the data already exists in the collection, then adding.
Note: I have reduced the columns here, but I have almost 10 Columns.
Set(
varExist,
LookUp(
MainRules,
ItemPoolName = ComboBox_ItemPoolName.Selected.Result && StartDate = ComboBox_StartDate.Selected.Value && Percentage = TextInput_Percentage.Text
)
);
If(
!IsBlank(varExist),
Notify(
"Cannot Add",
NotificationType.Error
),
If(
!IsBlank(
Patch(
MainRules,
Defaults(MainRules),
{
ItemPoolName: ComboBox_ItemPoolName.Selected.Result,
StartDate: ComboBox_StartDate.Selected.Value,
Percentage: TextInput_Percentage.Text,
}
)
),
If(
!IsBlank(
Patch(
'[dbo].[RulesData]',
DropColumns(
MainRules,
"RowNumber"
)
);
),
Notify(
"successful",
NotificationType.Success
),
Notify(
"Error",
NotificationType.Error
)
)
)
)
);