<objectService>.rollback
The <objectService>.rollback API rolls back all changes of all objects of an object service to its previous sync state.
Volt MX Iris (JavaScript)
Note:
- Supported for iOS and Android channels from V8 SP2 onwards.
- Supported for all channels from V8 SP4 onwards.
Signature
<VMXObjSvc>.rollback(successCallback, failureCallback)
Parameters
Parameter | Type | Description | Required |
successCallback | Function | The function is invoked on successful rollback. | Yes |
failureCallback | Function | The function is invoked on an error with the cause of failure as an argument upon Rollback failure. | Yes |
Return Type
void
Example
var orgObjectService = new voltmx.sdk.VMXObjSvc("Organization");
function successCallback(result) {
//result contains boolean true
voltmx.print("ObjectService level rollback successful")
}
function failureCallback(error) {
voltmx.print("ObjectService rollback failed with error: " + JSON.stringify(error));
}
orgObjectService.rollback(successCallback, failureCallback);
Android (Java)
Signature
void <VMXObjSvc>.rollback(final VMXCallback callback)
Parameters
Parameter | Type | Description | Required |
callback | VMXCallback | Application implements onSuccess and onFailure methods of VMXCallback interface. | Yes |
Return Type
void
Example
VMXObjSvc orgObjectService = new VMXObjSvc("Organization");
try {
orgObjectService.rollback(new VMXCallback() {
@Override
public void onSuccess(Object object) {
Log.d("ObjectServiceSync", "ObjectService rollback successful");
}
@Override
public void onFailure(Object error) {
OfflineObjectsException e = (OfflineObjectsException) error;
Log.e("ObjectServiceSync", "ObjectService rollback failed with error: " + e.getMessage());
}
});
} catch (Exception e) {
Log.e("ObjectServiceSync", "ObjectService rollback failed with error:" + e.getMessage());
}
iOS (Objective C)
Signature
void <VMXObjSvc>
rollback:(VMXSuccessCompletionHandler)onSuccess
onFailure:(VMXFailureCompletionHandler)onFailure
Parameters
Parameter | Type | Description | Required |
onSuccess | VMXSuccessCompletionHandler | The method called after a successful rollback. | Yes |
onFailure | VMXFailureCompletionHandler | The method called on rollback failure. | Yes |
Return Type
void
Example
VMXObjSvc * orgObjectService = [
[VMXObjSvc alloc] initWithName: @"Organization"
error: & ;error
];
[orgObjectService rollback: ^ (id object) {
NSLog(@"Object service rollback successful");
}
onFailure: ^ (id object) {
OfflineObjectsError * error = (OfflineObjectsError) object;
NSLog(@"Rollback failed with error: %@", [error.userInfo localizedDescription]);
}
];