How to preserve borders, merged cells & formula when using SetValue() function in AppScript?

I have recently written a code that fetches a range of date & sets it on another sheet. It works fine, but the set data is a little hard to read because the table borders/alignment/formula are not preserved. Is there a way that this can be preserved? The script: function saved() { //Source link var… Read More How to preserve borders, merged cells & formula when using SetValue() function in AppScript?

How to extract a username from an email address using Google App Script

I’m using the following script to get the user’s email address: function getEmail() { var userEmail = Session.getActiveUser().getEmail() Logger.log(userEmail); } It logs something like this: username@domain.com I’d like to extract the username (everything to the left of @) and log it. >Solution : About It logs something like this: username@domain.com, when your showing script is… Read More How to extract a username from an email address using Google App Script

How do I convert this textFinder to only return the email it finds in a specific column?

I currently have a Spreadsheet table of employee details. The code below works fine as long as the email is unique (only one occurrence in the table’s column E). However, other user emails are also found in the supervisor/manager columns email, which results into the code below referencing that first email occurrence and thus messing… Read More How do I convert this textFinder to only return the email it finds in a specific column?

Resize multidirectional arrays JavaScript Google script

I need to resize arrays by adding empty new columns and empty new rows. Ex newRows = 2 newCols = 3 (1s are just placeholder for any data) arr= [ [1,1,1,1], [1,1,1,1], [1,1,1,1], ]; To arr= [ [1,1,1,1,"","",""], [1,1,1,1,"","",""], [1,1,1,1,"","",""], ["","","","","","",""], ["","","","","","",""], ]; I can get the new empty cols but not the new empty… Read More Resize multidirectional arrays JavaScript Google script

How to replace part of a string using the slice method with an IF condition

I have the following script which is required to remove characters in a string leaving only the characters which follow the ">" character. For example, "GOOD > WEEKEND". When the script runs the output should be "WEEKEND". As there is one space after ">" i’m using slice(v.indexOf(">")+2) The problem is everytime the script runs it… Read More How to replace part of a string using the slice method with an IF condition

Turning single values and arrays into arrays including zeros as single value

While I was searching for a good way to check if a function variable is an array or a single variable and then turn both into arrays for further processing, I came across this post. The answer provided by @VoteyDisciple var eventsArray = events ? [].concat(events) : []; works great for me until events is… Read More Turning single values and arrays into arrays including zeros as single value

Turning single values and arrays into arrays including zeros as single value

While I was searching for a good way to check if a function variable is an array or a single variable and then turn both into arrays for further processing, I came across this post. The answer provided by @VoteyDisciple var eventsArray = events ? [].concat(events) : []; works great for me until events is… Read More Turning single values and arrays into arrays including zeros as single value

How can I map the object key and value in option HTML tags in appscript

I am retrieving this below object from a function in Code. gs. I would like to pass the key-value pair into my HTML drop-down button. How can I map the object key and value in option HTML tags? HTML <div class="form-group"> <? var data = listAccounts() ?> <optgroup label="Ad Accounts"> <? for (i=0; i<data.length; i++)… Read More How can I map the object key and value in option HTML tags in appscript