public static void runExample(
      AdManagerServices adManagerServices, AdManagerSession session, long customFieldId)
      throws RemoteException {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService =
        adManagerServices.get(session, CustomFieldServiceInterface.class);

    // Create a statement to select a custom field.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("WHERE id = :id")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("id", customFieldId);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get custom fields by statement.
      CustomFieldPage page =
          customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CustomField customField : page.getResults()) {
          System.out.printf(
              "%d) Custom field with ID %d will be deactivated.%n", i++, customField.getId());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of custom fields to be deactivated: %d%n", totalResultSetSize);

    if (totalResultSetSize > 0) {
      // Remove limit and offset from statement.
      statementBuilder.removeLimitAndOffset();

      // Create action.
      com.google.api.ads.admanager.axis.v201808.DeactivateCustomFields action =
          new com.google.api.ads.admanager.axis.v201808.DeactivateCustomFields();

      // Perform action.
      UpdateResult result = customFieldService.performCustomFieldAction(
          action, statementBuilder.toStatement());

      if (result != null && result.getNumChanges() > 0) {
        System.out.printf("Number of custom fields deactivated: %d%n", result.getNumChanges());
      } else {
        System.out.println("No custom fields were deactivated.");
      }
    }
  }
public static void runExample ( AdManagerServices adManagerServices , AdManagerSession session , long customFieldId ) throws RemoteException { CustomFieldServiceInterface customFieldService = adManagerServices . get ( session , CustomFieldServiceInterface . class ) ; StatementBuilder statementBuilder = new StatementBuilder ( ) . where ( "WHERE id = :id" ) . orderBy ( "id ASC" ) . limit ( StatementBuilder . SUGGESTED_PAGE_LIMIT ) . withBindVariableValue ( "id" , customFieldId ) ; int totalResultSetSize = 0 ; do { CustomFieldPage page = customFieldService . getCustomFieldsByStatement ( statementBuilder . toStatement ( ) ) ; if ( page . getResults ( ) != null ) { totalResultSetSize = page . getTotalResultSetSize ( ) ; int i = page . getStartIndex ( ) ; for ( CustomField customField : page . getResults ( ) ) { System . out . printf ( "%d) Custom field with ID %d will be deactivated.%n" , i ++ , customField . getId ( ) ) ; } } statementBuilder . increaseOffsetBy ( StatementBuilder . SUGGESTED_PAGE_LIMIT ) ; } while ( statementBuilder . getOffset ( ) < totalResultSetSize ) ; System . out . printf ( "Number of custom fields to be deactivated: %d%n" , totalResultSetSize ) ; if ( totalResultSetSize > 0 ) { statementBuilder . removeLimitAndOffset ( ) ; com . google . api . ads . admanager . axis . v201808 . DeactivateCustomFields action = new com . google . api . ads . admanager . axis . v201808 . DeactivateCustomFields ( ) ; UpdateResult result = customFieldService . performCustomFieldAction ( action , statementBuilder . toStatement ( ) ) ; if ( result != null && result . getNumChanges ( ) > 0 ) { System . out . printf ( "Number of custom fields deactivated: %d%n" , result . getNumChanges ( ) ) ; } else { System . out . println ( "No custom fields were deactivated." ) ; } } }
Runs the example.

@param adManagerServices the services factory.
@param session the session.
@param customFieldId the ID of the custom field to deactivate.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.