Simple script not running

62 views
Skip to first unread message

Osvaldo

unread,
Mar 18, 2023, 8:07:59 AM3/18/23
to Google Apps Script Community
Hi all,

I have a (one may think) very easy script that I run every 5 minutes. The script is the following:
function Currency() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('M:M').activate();
  spreadsheet.getActiveRangeList().setNumberFormat('[$£-809]#,##0');
  SpreadsheetApp.flush();
};

It's purpose is the following: whenever I import data from JIRA, it is a number-type field, but I cant to present it as a currency format, therefore with such script I simply change the format so as to display it on Google Datastudio (currently Looker Studio).

The problem is that it's not working whenever it's timedrive, and only works whenever I manually run it...

Also, if anyone knows a google sheets function to set a different column referenceing that column "M:M" and get it on a currency format (it has to be currency, text() does not work since I'll need to aggregate it later on), that'd be appreciated as well,

Happy weekend! :)

Any thoughts?

Best regards!!

Scott Bennett

unread,
Mar 18, 2023, 8:16:23 AM3/18/23
to google-apps-sc...@googlegroups.com
I think you need to use getactiverange not getactiverangelist

Scott Bennett


Sent from my iPhone 

On Mar 18, 2023, at 7:08 AM, Osvaldo <osval...@gmail.com> wrote:

Hi all,
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/b2967825-9112-4263-bfcc-11e0414181e6n%40googlegroups.com.

Chris Tales

unread,
Mar 19, 2023, 2:49:07 PM3/19/23
to Google Apps Script Community
This should do - no need to activate the range, nor assign variables to make changes you're looking for. It's also good practice to name functions in lower case & in a descriptive fashion
function setCurrencyFormatToColM() {
SpreadsheetApp.getActive().getRange('M:M').setNumberFormat('[$£-809]#,##0')
// SpreadsheetApp.flush(); optional
};

Osvaldo

unread,
Mar 21, 2023, 1:45:13 AM3/21/23
to Google Apps Script Community
This worked, thanks so much!!!

Took note of your advise and will apply it :)

Reply all
Reply to author
Forward
0 new messages