I faced this issue during building an application using ArcGIS JS API 3.x and after making some search I found the solution:
Read this link first especially the part of example one:
https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service-.htm
You will see you can send request with edits as an array and use id for each layer/table in your map service and each layer/table in edits array can be contains adds, updates or deletes
Read else the part of rollbackOnFailure, this parameter will handle what you want.
request(
urlOfFeatureService + "applyEdits?token=" + token,
{
httpMethod: "POST",
authentication: new UserSession({
token: token,
}),
params: {
f: "json",
rollbackOnFailure:true,
edits:
// will be like that
[
{
id:0, //refer to the layer/table id in the feature server
deletes:[
//objectIDs
],
adds:[
//geometry, attributes in case of layer
// attributes in case of table
],
updates:[
//attributes inclue objectID
]
},
{
id:1, //refer to the layer/table id in the feature server
deletes:[
//objectIDs
],
adds:[
//geometry, attributes in case of layer
// attributes in case of table
],
updates:[
//attributes inclue objectID
]
},
// ..... and so on
]
},
}
).then((res) => {
//if all requests success
}).catch(err=>{
//if one or more requests fail
//but the suitable message to user
});