In this app there are some trainings and users apply these trainings. Each training has their quota.
If the two users apply the same training which has 1 quota at the same time , I need to allow only first user, not another user.
But when the two users apply this training which has 1 quota at the same time, two items created and they got this error:
Network error when using patch function: conflicts exist with changes on the server, please reload
My apply formula is like that:
If(
ThisItem.Kontenjan - varBasvuran > 0,
IfError(
If(
CountRows(
Filter(
colEgitimKatılımcılar,
BasvuruTipi.Value = "Yedek",
isDelete = false,
SeçilenEğitim.Value = ThisItem.Title
)
) = 1,
Patch(
'Egitim Katılımcılar',
LookUp(
colEgitimKatılımcılar,
BasvuruTipi.Value = "Yedek" And isDelete = false And SeçilenEğitim.Value = ThisItem.Title
),
{BasvuruTipi: {Value: "Asil"}}
),
Patch(
'Egitim Katılımcılar',
Defaults('Egitim Katılımcılar'),
{
Kullanıcı: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
Claims: User().Email,
Department: "",
DisplayName: User().FullName,
Email: User().Email,
JobTitle: "",
Picture: ""
},
SeçilenEğitim: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedLookup",
Id: LookUp(
colEgitimler,
Title = ThisItem.Title
).ID,
Value: LookUp(
colEgitimler,
Title = ThisItem.Title
).Title
},
Kategori: LookUp(
colEgitimler,
Title = ThisItem.Title
).Kategori.Value,
DönemBitisTarihi: LookUp(
colEgitimler,
Title = ThisItem.Title
).'Dönem Bitiş Tarihi',
BasvuruTipi: {Value: "Asil"}
}
)
);
Refresh(Egitimler); //trainings
Patch(
Egitimler,
ThisItem,
{
BasvuruSayisi: LookUp(
Egitimler,
ID = ThisItem.ID
).BasvuruSayisi + 1
}
),
Notify(
"Internal error: originated on " & FirstError.Source & ", surfaced on " & FirstError.Observed,
NotificationType.Error
),
Notify(
"Başvurunuz alınmıştır.",
NotificationType.Success,
2000
)
);
Refresh(Egitimler);
,
Notify(
"Kontenjan sayısı dolmuştur.", // it says There is no enough quota !
NotificationType.Error
)
)
;
ClearCollect(
colEgitimler,
Egitimler
);
ClearCollect(
colEgitimKatılımcılar,
Filter(
'Egitim Katılımcılar',
StartsWith(
Kullanıcı.Email,
Office365Users.MyProfileV2().mail
)
)
);
How can I avoid this error and how can I avoid applying the insufficient quota?
Maybe revert function, but how?