This is the legacy documentation for Google Ads scripts. Go to the current docs.

Budget Orders

Stay organized with collections Save and categorize content based on your preferences.

Retrieve base spending limit of budget order

function getBaseSpendingLimit() {
  var budgetOrderIterator = AdsApp.budgetOrders().get();
  while (budgetOrderIterator.hasNext()) {
    var budgetOrder = budgetOrderIterator.next();
    var limitText = "";
    if (budgetOrder.getSpendingLimit() == null) {
      limitText = "unlimited";
    } else if (budgetOrder.getTotalAdjustments() == null) {
      limitText = budgetOrder.getSpendingLimit();
    } else {
      limitText = budgetOrder.getSpendingLimit() -
          budgetOrder.getTotalAdjustments();
    }
    Logger.log("Budget Order [" + budgetOrder.getName() +
        "] base spending limit: " + limitText);
  }
}

Retrieve the active budget order

function getActiveBudgetOrder() {
  // There will only be one active budget order at any given time.
  var budgetOrderIterator = AdsApp.budgetOrders()
      .withCondition('status="ACTIVE"')
      .get();
  while (budgetOrderIterator.hasNext()) {
    var budgetOrder = budgetOrderIterator.next();
    Logger.log("Budget Order [" + budgetOrder.getName() +
        "] is currently active.");
  }
}

Retrieve all budget orders

function getAllBudgetOrders() {
  var budgetOrderIterator = AdsApp.budgetOrders().get();
  while (budgetOrderIterator.hasNext()) {
    var budgetOrder = budgetOrderIterator.next();
    Logger.log("Budget Order [" + budgetOrder.getName() + "]");
  }
}