account.getCurrencyCode() returns null

14 views
Skip to first unread message

Google Ads Scripter

unread,
May 5, 2020, 3:36:29 AM5/5/20
to Google Ads Scripts Forum
How, hope all is doing well!

So I can't return the currency, how come?

Script:

function main() {
   
    // Select the accounts to be processed.
    var accountIterator = MccApp.accounts()
    .withIds(['XXX'])
    .get();
    // First we take the accountIterator variable from before
    while (accountIterator.hasNext()) {
    // And, for each account, we save the data into another variable
    var account = accountIterator.next();
    // Switch to the account you want to process.
    MccApp.select(account);
    // Now we can do something with the selected account
        
      var nameAccount = account.getName(); // THIS WORKS FINE
      var account_currency = account.getCurrencyCode(); // DOESN't WORK.
      if (account_currency = 'USD' | 'EUR' ) {
        var max_cpc = 149;
      }
      else {
        var max_cpc = 1499;
      }
...


Thanks in advance :-)

Google Ads Scripts Forum Advisor

unread,
May 5, 2020, 5:19:19 AM5/5/20
to adwords...@googlegroups.com
Hi,

Thanks for posting your concern.

I tried using your code on my test Google Ads account and logged the returned value of the account.getCurrencyCode(), however, I wasn't able to replicate the issue as the currency of each account was returned.

Furthermore, it appears that the implementation of this condition is not correct if (account_currency = 'USD' | 'EUR' ), it will always fall to the second block of if-statement. With this, I would recommend replacing the said condition with the line of code below if you want an OR condition for USD and EUR.
if (account_currency == 'USD' || account_currency == 'EUR' ) 

If the issue persists after trying this suggestion, then let me know and provide the customer ID and the name of the script via Reply privately to author option.

Regards,
Ejay
Google Ads Scripts Team

ref:_00D1U1174p._5004Q1zKB0H:ref

Google Ads Scripter

unread,
May 5, 2020, 8:33:22 AM5/5/20
to Google Ads Scripts Forum
Wopsy, it was the wrong if-statement which caused the problem. Thanks for the help!
Reply all
Reply to author
Forward
0 new messages