Skip to main content

zdelete Method

Zuora

zdelete Method

Overview

This article describes the Order Builder zdelete() method. The zdelete() method uses the Zuora delete() method to delete Zuora objects or records.

Syntax

List<zApi.DeleteResult> zdelete(String ztype, String[] ids)

Input Parameters

The zdelete() method takes the following input parameters.

Parameter Type Description
ztype String Indicates the type of object to be deleted
ids String[] A list of the records to be deleted

Response

The zdelete() method returns a list of zApi.DeleteResult that provides the results of the Zuora delete() call.

zApi.DeleteResult

The DeleteResult has the following properties.

Properties Type Description
errors List If the delete failed, this contains an array of Error objects.
id String ID of the deleted object
success Boolean A boolean field indicating the success of the delete operation. If the delete was successful, it is true. Otherwise, false.

Exceptions

The zdelete() method uses the following exception classes to catch the exception when an error occurs during the delete.

  • zAPIException
  • zForceException
  • zRemoteException

Sample Code

// zApiInstance should be instantiated and the login() method must
// have been invoked prior to invoking any other method on the
// object

try {
List<String> ids = new List<String>();
ids.add('4028e69926e9852f0126ead18246043f');

List<Zuora.zApi.DeleteResult> results =
zApiInstance.zdelete('Account',ids);

for (Zuora.zApi.DeleteResult result : results) {
if (result.Success){
//get the deleted object id
String deletedId = result.Id;
//more code here...
} else {
//failure
//get the errors
Zuora.zObject[] errors = result.errors;
for (Zuora.zObject error : errors) {
String errorCode = (String)error.getValue('Code');
String message = (String)error.getValue('Message');
//more code here...
}
}
}
} catch (Zuora.zRemoteException ex) {
if ('INVALID_FIELD' == ex.code) {
// An invalid field was specified
//more code here...
} else {
//more code here...
}
} catch (Zuora.zAPIException ex) {
ex.getMessage();
//more code here...
} catch (Zuora.zForceException ex) {
//more code here...
}