Hello,
I tried posting a question on this over an hour ago and it hasn't showed up at all. But for the past year, my organization has been using the script below to create search campaigns. This script has ran thousands of times over that year without any issues until yesterday. The script continues to run without any errors, but the campaigns simply do not show up and the applicable accounts don't have any records of bulk uploads. Is there something I am missing? As you can see in the function below, I have logged the various pieces of information that the script is pulling from the spreadsheet to ensure that the script is indeed making them into variables. Thanks!
function createCampaigns(){
var spreadsheetUrl = '...';
var spreadsheet = SpreadsheetApp.openByUrl(spreadsheetUrl);
var sheet = spreadsheet.getSheetByName('...');
var num = sheet.getRange("CF2").getValue();
if(num>0) {
var data = sheet.getRange(6,79,num,8).getValues();
for (i=0 ; i<num ; i++){
var row = data[i];
var uploadCode = row[7];
if(uploadCode>0){
var rowNumber = row[5];
//Logger.log(rowNumber);
var accountID = row[0];
//Logger.log(accountID);
var campaignName = row[1];
//Logger.log(campaignName);
var budgetAmount = row[3];
//Logger.log(budgetAmount);
var bidStrat = row[4];
//Logger.log(bidStrat);
var campStatus = row[2];
//Logger.log(campStatus);
var account_iter = AdsManagerApp.accounts()
.withIds([accountID])
.get();
while (account_iter.hasNext()){
var account = account_iter.next();
var accountName = account.getName();
AdsManagerApp.select(account);
try {
var campaign_iter = AdsApp.campaigns()
.withCondition("Name = '" + campaignName + "'")
.get();
while (campaign_iter.hasNext()){
var campaign = campaign_iter.next();
var name = campaign.getName();
var campID = campaign.getId();
sheet.getRange(rowNumber, 87, 1, 1).setValue(campID);
removeUploadedCampaigns();
}
}
catch(e) {
Logger.log(e);
}
var columns = [
"Campaign", "Budget", "Bid Strategy type", "Campaign type", "Campaign status", "Currency code", "Budget type", "Status", "Customer ID", "Campaign subtype"
];
var upload = AdsApp.bulkUploads().newCsvUpload(columns);
upload.append({
"Campaign": campaignName,
"Budget": budgetAmount,
"Bid Strategy type": bidStrat,
"Campaign type": "Search Only",
"Campaign status": campStatus,
"Currency code": "USD",
"Budget type": "Daily",
"Status": campStatus,
"Customer ID": accountID,
"Campaign subtype": "Standard"
});
//Logger.log(campaignName);
upload.forCampaignManagement();
upload.apply();
try {
var campaign_iter = AdsApp.campaigns()
.withCondition("Name = '" + campaignName + "'")
.get();
while (campaign_iter.hasNext()){
var campaign = campaign_iter.next();
var name = campaign.getName();
var campID = campaign.getId();
sheet.getRange(rowNumber, 87, 1, 1).setValue(campID);
removeUploadedCampaigns();
}
}
catch(e) {
Logger.log(e);
}
}
}
}
var campUpComp = sheet.getRange("F2").getValue();
Logger.log(campUpComp);
}
else {
var NoCamp = sheet.getRange("F3").getValue();
Logger.log(NoCamp);
}
}