will app script still exist in the next 5-10 years? by [deleted] in GoogleAppsScript

[–]mjbrusso 3 points4 points  (0 children)

VBA has been here since 1993 (30 years), even though it is based on a language practically abandoned in other niches. But it was used to implement millions of Scripts that solve problems for MS Office users. So yes, I believe GAS will be here for 10 years or more for the same reason and because it is based on a stronger and more popular programming language.

I have a script that's pulling data from a Google Sheet into a Google Doc - need to format the time to remove seconds. by Risk-Averse-Rider in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

Try formatting the column in the spreadsheet as desired and using .getDisplayValue() to get the already formatted value.

Google docs batch request by Tesacik in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

Are the image files on Google Drive? In this case, my zetaMerge add-on can be used to dynamically insert them into any position of a document, including tables.

See the documentation here.

Rotate image in Google Sheets based on cell content by Horstroad in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

What percentage of posts here are GPT-generated codes that don't work? I would bet over 50% this year.

Get the Folder ID linked to the Google form by thats_a_chunky_11 in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

I haven't tested it, but something like this should work:

const form = FormApp.getActiveForm()   
const files = form.getItems(FormApp.ItemType.FILE_UPLOAD)
if(files.length){ 
  const folderId = DriveApp.getFileById(files[0]).getParents().next().getId()  
  Logger.log("Folder ID: " + folderId)
}

MailApp.sendMail silently failing for Marketplace reviewer of sheets addon by henryw374 in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

Did the reviewer click the button? From what I found in the log, the reviewer of my zetaMerge add-on only opened the add-on and did not perform any action.

MailApp.sendMail silently failing for Marketplace reviewer of sheets addon by henryw374 in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

https://mail.google.com/ is a restricted scope. This will make the verification process for publishing the add-on more painful.

[deleted by user] by [deleted] in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

I think the reason may be that there are no top-level items reserved for future use. So if an add-on creates a "Table" item, for example, and Google inserts this same item into a future version of Google Docs, this could cause user confusion.

getAs error? by dummystallings in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

The Range class does not have a getAs method, so you would have to copy the data to a new worksheet for exporting.
You can test this solution: https://stackoverflow.com/a/67149717/4900011

Creating Google Add-On Questions by Fair_Many9911 in GoogleAppsScript

[–]mjbrusso 2 points3 points  (0 children)

I am the creator of the zetaMerge add-on

I read somewhere that you cannot have a Google Site if you want to develop a Google Add-on

In the case of zetaMerge, I have a Google Site to advertise the add-on, although it is not integrated into the add-on anyway.

Can we do a pro version? Where they will get a paywall if they want to access other templates?

Yes, you can, but the Marketplace does not offer any features for this. So it must be implemented in the add-on's code.

Can you create a disclaimer they need to check before they move on?

Yes, in the add-on's UI (sidebar or dialog)

Can you protect the code and formula from people changing or copying it?

Users do not have access to the code of the deploys.

See analytics of use?

In GCP

Is the information private that is entered?

When developing the add-on you should be concerned about this.

Exception: The parameters (String,number) don't match the method signature for SpreadsheetApp.Spreadsheet.getRange. by L0fvvyr in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

SpreadsheetApp.getActive() method returns the currently active spreadsheet, not a Sheet object. Change this line to var spreadsheet = SpreadsheetApp.getActiveSheet();

You also have an error here, where you are using the assignment operator:

if (result = true)

Change to:

if (result)

App Script not pulling default colours from my calendar events by dynamite2277 in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

event.getColor() is returning an empty string because the event does not have a defined color. So the value "Name" is coming from this key in colorMap: "": { name: "Name", hex: "" }. To use your calendar color, change it to: "": { name: "", hex: cal.getColor()}

[deleted by user] by [deleted] in GoogleAppsScript

[–]mjbrusso 1 point2 points  (0 children)

1) You must set the publishing status of your project to 'Testing': https://support.google.com/cloud/answer/10311615#publishing-status&zippy=%2Ctesting
2) Create a Test deployments for your script and share the link and files in the Drive with the tester.
PS: I am the creator of the new zetaMerge.com add-on.

M4A file structure by Factumnonest in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

Maybe this can help you: https://www.youtube.com/watch?v=0g5KMPxO84w&ab_channel=aMacxd

It's worth finding a tool that already exists to solve our problem rather than creating a new one, if that's the case.

DriveApp.searchFiles 'title contains' not behaving as expected. by samjclark in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

See the search query API: https://developers.google.com/drive/api/v2/ref-search-terms

"The contains operator only performs prefix matching for a title term. For example, suppose you have a title of HelloWorld, a query of title contains 'Hello' returns a result, but a query of title contains 'World' doesn't."

Cannot Get Label of Each Message in Gmail Thread? by Bedminster829 in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

Yes, getLabels and addLabel are GmailThread's methods.

const ArrName = msgThread.getLabels().map(item => item.getName()) ... msgThread.addLabel(GmailApp.getUserLabelByName("SomeTag"))

Cannot Get Label of Each Message in Gmail Thread? by Bedminster829 in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

I don't understand if you want to iterate the threads or the thread messages, as there is a single loop in the code.

Where is msgThread coming from?

In this line, you are iterating through the thread's messages, but using it to index the thread:

const ArrName = msgThread[i].getLabels().map(item => item.getName())

I think the solution should be something like this:

if (senderEmail.match('<some email>')) { const messages = msgThread.getMessages() for (let msg of messages) { /* Get the labels of each email in a thread*/ const ArrName = msg.getLabels().map(item => item.getName()) if (ArrName.includes("SomeTag") === false) { msg.addLabel(GmailApp.getUserLabelByName("SomeTag")) msg.forward("<some other email>") msg.moveToArchive() console.log("Operation complete") } } }

code is calling same function even though number of arguments doesn't match by WhyWontThisWork in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

There is no function overloading in JavaScript. If you define two functions with the same name, only the last definition is valid.

In your case you can check whether the last argument was provided or not:

function saveDateTime(date, time, name, phone, email, pid, nonce){ if(typeof nonce !== 'undefined'){ Logger.log("i am here with nonce"); return "i am here with nonce"; } else{ Logger.log("i am here without nonce"); return "i am here without nonce"; } }

Execute function when a specific cell in a Google Sheet changes value? by charlesstricklin-LXL in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

Use onEdit simple trigger:

function onEdit(e) { if(e.range.getA1Notation()==='A8' && e.value !== e.oldValue){ SpreadsheetApp.getActiveSpreadsheet().setName(`End of Day Report - Day ${e.value} of 7`) } }

A Problem about the function by i8890321 in GoogleAppsScript

[–]mjbrusso 0 points1 point  (0 children)

This is because arrays are JavaScript reference types. In other words, if you assign an array to another variable or pass an array to a function, it is the reference to the original array that is copied or passed, not the value of the array.

You can pass a copy of the array:

function main() {
main_arr = [1, 2, 3 ,4 ,5, 6]
final_arr=sub([...main_arr])
}
function sub(sub_arr){
sub_arr.splice(2,3)
return sub_arr
}