Skip to main content

zupdate Method

Zuora

zupdate Method

Overview

This article describe the Order Builder zupdate() method. The method uses the Zuora update() method to update Zuora objects in Z-Billing.

Syntax

List<zApi.SaveResult> zupdate(List<zObject> zobjects)

Input Parameter

The zupdate() method uses the following parameter.

Parameter Type Description
zobjects List<zObject>  A list of Zuora objects to be updated in Z-Billing

Response

The zupdate() method returns a list of zApi.SaveResult object that provides the result of the Zuora update() call.

zApi.SaveResult

The SaveResult object includes the following properties.

Property Type Description
Errors List of zObjects If the update failed, this contains an array of error objects.
Id String ID of the updated object.
Success Boolean If the update was successful, true. Otherwise, false.

Exceptions

The zupdate() method throws an exception if there is an error. The following classes are used to catch the exception:

  • 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 {
   Zuora.zObject acc = new Zuora.zObject('Account');
   acc.setValue('Id','4028e69926e9852f0126ead18246043f'); //an existing account
   acc.setValue('Name','New Acme - Updated');

   List<Zuora.zObject> objs = new List<Zuora.zObject> {acc};
   List<Zuora.zApi.SaveResult> results = zApiInstance.zupdate(objs);

   for (Zuora.zApi.SaveResult result : results) {
      if (result.Success){
         //get the updated id
         String updatedId = result.Id;
         //more code here...
      } else {
         //failure
         //more code here...
         //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...
}