I'm reviewing an old script that copied ads to a new ad group. What I'm trying to do is update expanded text ads from the original text ad format.
// Now we have to make ads for this ad group. First find all the ads from the old group.
var adList = AdsApp.ads().withCondition("CampaignName = '" + currentCampaignName + "'").withCondition("AdGroupName = '" + adGroup.getName() + "'").withCondition("Status = ENABLED").get();
var adOps = [];
while (adList.hasNext()) {
var oldAd = adList.next();
adOps.push(
newAdGroup.newAd().expandedTextAdBuilder()
.withHeadlinePart1(oldAd.getHeadlinePart1()).withHeadlinePart2(oldAd.getHeadlinePart2()).withHeadlinePart3(oldAd.getHeadlinePart3())
.withDescription(oldAd.getDescription()).withDescription1(oldAd.getDescription1()).withDescription2(oldAd.getDescription2())
.withPath1(oldAd.getPath1()).withPath2(oldAd.getPath2())
.withFinalUrl(oldAd.urls().getFinalUrl()).withFinalUrlSuffix(oldAd.urls().getFinalUrlSuffix())
.build());
}
// Review success or failure of ad creation.
for (var i = 0; i < adOps.length(); i++) {
if (adOps[i].isSuccessful())
Logger.log('New ad built: ' + oldAd.getType() + ' ad type has been created, in the "' + newName + '" ad group.');
else
Logger.log('Error from ad [' + oldAd.getHeadlinePart1() + ']: ' + adOps[i].getErrors());
}
When testing, it's throwing the "GENERIC_ISSUE : Failed to create AdWords entity. : " error. This code worked previously before using expanded text ads.