AdOperation

Contains the methods for determining whether the ad was successfully added. For information about builders, operation objects, and performance considerations, see What are builders?

Because calling any of this object's methods forces Scripts to flush the build queue, be sure to read the performance considerations carefully.

Example usage:

    if (operation.isSuccessful()) {
        var ad = operation.getResult();
    }
    else {
        for (var error of operation.getErrors()) {
            Logger.log(`${error}\n`);
        }
    }

Methods

Method Name Return Type Description
getErrors string[] Gets any errors that occurred when adding the ad.
getResult Ad Gets the ad that was added.
isSuccessful Boolean Gets a Boolean value that indicates whether the add operation succeeded.

getErrors

Gets any errors that occurred when adding the ad.

Returns

Type Description
string[] An array of error codes if the operation failed; otherwise, an empty array. For example, if you forget to specify the final URL, the call returns CampaignServiceInvalidAdDestinationUrl. For a description of these codes, see Operation error codes.

getResult

Gets the ad that was added.

Returns

Type Description
Ad The ad that was created if the operation succeeded; otherwise, null.

isSuccessful

Gets a Boolean value that indicates whether the add operation succeeded.

Returns:

Type Description
Boolean Is true if the operation succeeded; otherwise, false.