AdWords
5.3K members online now
5.3K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

Adwords Script - Removing Overlapping Schedule from Ad Schedule Script

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I am working on the ad schedule script here to change my daily ad schedule across all my campaigns but when I run the campaign I am receiving the error message "Some of your selections overlap with your existing ad schedule. To continue, remove any overlapping schedules." Is there a way in the script to remove the previous ad schedule to insert the new one?

 

Thank you. 

1 Expert replyverified_user

Re: Adwords Script - Removing Overlapping Schedule from Ad Schedule Script

Top Contributor
# 2
Top Contributor

Hi @Avi B AdSchedule objects have a "remove" method, so you could use that.

 

https://developers.google.com/adwords/scripts/docs/reference/adwordsapp/adwordsapp_adschedule

 

I'm not familiar with the script itself or how it works, but if it creates an entire set of schedules you'd probably want to create a function that iterates through all of the schedules for a given Campaign and removes them as the first step before creating new ones.  The getAdSchedules function on the linked page is 95% of what you need, just remove the logger lines and replace with:

 

adSchedule.remove();

and rename the function.

 

Jon

AdWords Top Contributor Google+ Profile | Partner Profile | AdWords Audits

Adwords Script - Removing Overlapping Schedule from Ad Schedule Script

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you Jon.

 

Unfortunately when I added "adSchedule.remove();", I get error messages within my script. Where exactly and how should I add this command to the below script so I do not receive error messages.

 

function main() {
var campaignIterator = AdWordsApp.campaigns().withCondition("Status = ENABLED").get();

while (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();

campaign.addAdSchedule('MONDAY', 9, 0, 15, 0);
campaign.addAdSchedule('TUESDAY', 9, 0, 15, 0);
campaign.addAdSchedule('WEDNESDAY', 9, 0, 15, 0);
campaign.addAdSchedule('THURSDAY', 9, 0, 15, 0);
}
}

 

Thank you so much.

Avi