Does anyone know if there is a way to use the Google Sheets API to get the email address of a people chip? It seems like the only values it will give me are the person's full name as displayed in the cell.
While trying to figure this out I discovered that the name turns into an email address if you use "Format > Clear Formatting". I hoped I could hack this by copying the value into a hidden sheet, clearing the formatting, and then get the email address there. But though Google Apps Script has a function for executing that on a cell, I have found no way to do it with the Sheets API. I tried clearing all the possible formats I could via batchUpdate with an updateCellsRequest but that isn't turning the people chip into an email address.
I'm at the point where if I really want to automate this, I will need to use the scripts API as well, to deploy and execute a tiny Apps Script just to run clearFormat on a cell. I'd like to avoid this much complication, especially since Apps Script doesn't work for service accounts.
As Tanaike mentioned this is not possible at the moment but there is already a feature request in the Google Issue tracker related to adding the people chips to the Sheets API. You can check the request here.
I would suggest posting a comment on it and explain why you are interested in this feature. Or if you think your request has a different approach you can also submit a new feature request for the Sheets API here.
Related
GOAL: I would like to know if there is any apps script code for listing all the inbox details of your current gmail account to a spreadsheet.
Currently after reading through all the possible functions and methods about Gmail in Apps Script, I have not found any way according to my knowledge as of how to gain this.
The link I am talking about is here: https://developers.google.com/apps-script/reference/gmail
For example:
You can use the GmailApp.getInboxThreads() to get the messages, and then SpreadsheetApp's Range.setValue(value) to set the value in a cell.
Of course you have to program your own logic into it. So share your code ;).
I've made a simple script in Google Apps Script. The script builds forms based on a spreadsheet, the script itself is part of the spreadsheet. It adds a menu item. People would like to use it. They are non-technical people, so I would like to make the installation of my script as easy as possible. With 'installation' I mean a way to 'import' my script into their spreadsheet and automatically set up the needed triggers so the menu item becomes visible. It should be possible for anyone to install it.
I've been thinking of the following solutions:
Publishing as an add-on: my script wouldn't qualify, and even then I can't wait for Google's approval.
Copy-paste. I don't like this, it's way too complicated.
I've looked at this question: https://stackoverflow.com/questions/5334751/how-do-i-share-a-script-i-wrote-with-my-co-workers-on-the-same-google-apps-accou, but the people wanting to install it are not on the same domain in my case. The question is also 3 years old.
EDIT: As it turns out, there doesn't seem to be a solution. I've filed a feature request here: https://code.google.com/p/google-apps-script-issues/issues/detail?id=4122&thanks=4122&ts=1403949074
If your Google Account administrator allows you, you can share scripts/spreadsheets outside your organisation either by sharing directly with another person with a Google Account (Gmail or Google Apps) or by making it public (share with a link or published online).
https://support.google.com/drive/answer/2494822?hl=en
Keep in mind that if you use the Script Properties to store values, each time someone uses the shared script it will overwrite the values. In a shared context it is best to use User Properties instead. This way each user can store their own values.
https://developers.google.com/apps-script/guides/properties
There is no way to import a script in an existing spreadsheet , the "normal" workflow is , in a way, the reverse process, that's to say create a sheet from an existing template that already has the script in it and start to work with that copy.
From your description I'm not sure this method could be useable but I'm afraid there is no other way if you want people who will be using it should not go into the script editor at all.
There would be a couple of functions to write that should run at install time and would create the triggers (if needed) and trigger the authorization process.
I made such a SS some time ago that needed authorizations and I added an "install" menu that made its use quite simple (example here on a friendly hosting site).
I know this is probably not the answer you were expecting but it was definitely too long to fit in a comment anyway.
I want to create an app which helps newbie employers to take some simple decisions. So, using their answers to a form, the app asks new questions based on previous responses, something similar to a decision tree. Is Google Form a good alternative to implement this? (something like this suggested here, but with more questions:
Are there alternatives based on Google Apps Script?
What you need is a Google Form with a lot of questions, whose answers redirect to different pages in the Form.
You can also use Google Apps Script Forms Service to create Forms through code (and you can use previous responses in old Forms to generate new content for new Forms dynamically).
A typical example of this would be:
Create a Google Form with several questions with redirects based on answers (decision trees).
Have the responses to that form go to a response Spreadsheet.
Run a script on the response Spreadsheet to generate new content using the Forms Service within Google Apps Script (or do this manually; both work).
Send out the new Form to employees by email (you can use Gmail Service to accomplish this) or however you prefer.
--> and repeat the process as needed.
At my work, I use Google Forms with redirects and scripts on the response Spreadsheets in order to process faculty requests using Google Apps Script, so this is definitely possible!
However, it should be noted that Google Apps Script cannot be used to dynamically generate content for Forms while the user is filling it out. See my question here.
I don't feel like typing a mass of code here, but there are two ways of accomplishing this (both of which would require a lot of script code):
You could potentially accomplish this by making a web app that automatically dumps the responses into a spreadsheet (limited space) or a document (which doesn't have to be human-readable). This won't give you the same UI, but it would work, assuming you are familiar with making web apps in the first place.
You could make a multi-page form that you could write some code to direct the person upon selection of whatever choice they make to go to the correct page. This other question may serve of use if you want to go this route (it likely will be a bit easier).
Writing to a Google Spreadsheet from Google App Scripts is described here:
https://developers.google.com/apps-script/storing_data_spreadsheets#writing
Which includes details of the setRowsData method.
I was wondering if there was a method for just setting an individual cell in the spreadsheet. I've searching Google and SO, but can't find anything yet. I'm guessing perhaps that setRowsData is the only way to go, but if there's an alternative setCellData call or similar I'd love to hear about it.
Many thanks in advance
p.s. profusely sorry if this isn't the right place to ask, but the Google App Script team is directing all questions to SO
The Range.setValue service to set a value of a cell. The range should be defined to the cell, for instance, the follwing code does it.
var range = SpreadsheetApp.getActiveSheet().getRange("A1");
Is it possible to get at calendar event attachments within google apps scripts? I realize that this is still a "google labs"-level feature, but getAttachments() would be really handy for some stuff I'm working on. Failing that, does the lab store its attachment data in a clever location (say, a tag containing a URL) that I could get at behind the scenes?
Not possible as far as I know. As you've mentioned, it is a Calendar Labs feature. Many regular features are not available in Apps Script, so it is tough to expect this one. You can try opening a feature request though