How to log users email in Google Apps Script - google-sheets

I'm trying to make a script that logs the date and time, and a user's email address when a button is pressed in Google Sheets. I can get the date and time values printed but whenever the button is pushed it just returns "Logger" instead of an email address. I'm also struggling to figure out how to change which cell the value is returned in, as the sheet is designed to log many users. Here's what I have so far, any help is appreciated.
edit, I've gotten the script to insert the user's email into a specified cell. Now I'm just wondering how to make it so it inserts the date and email into the next available row.
function setDate() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("N2").setValue(new Date());
var email = Session.getActiveUser().getEmail();
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Form Responses 1").getRange("O2").setValue(email);
}

Refer to getActiveUser()
If security policies do not allow access to the user's identity, User.getEmail() returns a blank string. [...] However, these restrictions generally do not apply if the developer runs the script themselves or belongs to the same Google Workspace domain as the user.

Related

Google Places Text Search API Issue

Requirement:
Need to search business through the address and in the result list Business name should return.
Problem:
When we search by only address of the business ( without business name ), then in the result list it returns only the address or place and does not return business name.
To get the business name in the result list, I had passed "Opennow = true" in the request, which works well and return business name in the results set whenever we search through only address.
But the challenge here is that, the Opennow = true returns only those businesses which opening hours are open at the search time, out of the opening hours it returns blank data.
I need the list of businesses with their name whenever we search through address only regardless of opening hours open or closed.
This is the API I am using to get text search data:
"https://maps.googleapis.com/maps/api/place/textsearch/json?query=&opennow=true&types=establishment&region=us&key="
I found resolution for your query in the google documentation:
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-hotelsearch
Could you try the above, surely, it requires modifications.
Hope that will solve your problem
Thanks

Can we validate the response from google form whether entered value exists or not using google forms script?

I need to collect unique data through google forms. So I have one primary key on first section, after submit of first section, if this value exists I need to display error message on this section otherwise move to next section where I collect all the data. Can this be possible through google form script ?

How can i trigger zendesk web widget after page reload?

I create custom ticket form in zendesk and passing some parameters (like customer name, customer email, and customers company name) from my database. then i found zE(identify) functions and saw this functions include just name and email object. but i need customers company names too. and it is just came after completely page reload.
So how can i refresh (or something) after database value completely reload?
sorry for my bad english
To execute zE function after page load you should be able to add it to a callback function from however you are loading the DB values.

Zapier: How to send data to my Node.js web app from ScheduleOnce using Zapier

Here is my workflow:
Person clicks on my ScheduleOnce link and schedules a meeting
Upon completing the ScheduleOnce booking form, the person clicks the done button
When this done button is clicked the person is redirected to a Node JS web app that displays an application page. This application page needs to be auto-populated with the information from the ScheduleOnce page.
Between step 2 and 3 is where Zapier comes in. I am trying to use Zapier to capture the data from the ScheduleOnce booking, which it is. Then I am trying to use a Zap to send that data to the page the person is redirected to, to auto-populate some of the fields.
I thought using the Code Javascript functionality would work but it does not. So then I was thinking about using the StoreClient option or the API. I am just confused on how to get the flow to work to access the data and auto-populate the fields on the next redirected page.
Some help would be greatly appreciated.
Here is the code I have for the Javascript option:
var store = StoreClient("Secret");
store
.setMany({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite})
.then(function() {
return store.getMany('firstName', 'lastName', 'email', 'mobilePhone', 'otherPhone', 'businessWebsite');
})
.then(function() {
callback();
})
.catch(callback);
David here, from the Zapier Platform team. This is a cool use case and is probably possible. Something you need to remember is that Zapier is running totally separately from the user, so interaction will have to be indirect. Zapier can't redirect your user anywhere, it can just store data in response to a button push.
In your case you can skip everything after the setMany, since you're not trying to use the values in the zap; you just need to store them (and verify that action completed without errors).
var store = StoreClient("Secret");
store
.setMany({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite})
.catch(callback);
You'll need to solve a couple of problems:
Speed. the user will reach your landing page before the zap completes (as it has to make a couple of HTTP round trips and execute code). You'll want to play them a 3 second loading gif, or put a waiting message and allow them to refresh the destination
Populating the page. I'm not sure what the nature of the destination is (best case scenario is that it's a server you control), but something will need to make an http request to store.zapier.com to retrieve the stored data and surface it in the view. This is easy if
Identifying the user. You'll need some way to identify the user getting redirected to the data you stored in StoreClient. If two users fill out the form in quick succession, the second one will currently overwrite the first. Plus, it seems to be semi-sensitive data that you don't just want available to anyone on your site. To that end, you'll probably want to store all of the data as a JSON string keyed by the user's email (or something else unique). That way, when I (the user) finish the form, I'm redirected to yoursite.com/landing?email=david#zapier.com, the backend knows to look for (the david#zapier.com key in store) and can render a view with the correct info.
To that end, I'd tweak the code to the following:
var store = StoreClient("Secret");
store
.set(inputData.email, JSON.stringify({firstName: inputData.firstName, lastName: inputData.lastName, email: inputData.email, mobilePhone: inputData.mobilePhone, otherPhone: inputData.otherPhone, businessWebsite: inputData.businessWebsite}))
.catch(callback);
Hope that points you in the right direction. You're working with a pretty complicated workflow, but I bet you can do it!

Does Google AdWords support automatically appending a different query string to a campaign's destination URLs for ads and sitelinks?

I have an existing Google ad campaign that geotargets a particular region. The destination URL of all the ads and sitelinks have the same query string appended to it ("area=astoria").
I now need to copy this campaign to 50 other campaigns, each of which will target a different region. Each campaign will have a different value for the area key, so for instance one campaign might use "area=manhattan" and another "area=bronx".
The campaign I'm cloning has many ads and sitelinks, all of which need to have the query string changed. I know how to manually change the destination urls, but it's an enormous amount of busy work...
As a workaround, is there a way to automatically append a different query string to all the destination URLs for ads and sitelinks in a particular campaign in Google AdWords?
To answer my own question, the answer is to use a Tracking Template on the Campaign level.
To do this, click into the Campaign you want to edit and click on the Settings tab. Then open the "Campaign URL options (advanced)" section and change the Tracking URL to something like this:
{lpurl}?area=whatever
You can click the TEST button to make sure your ads work. Your sitelinks should also have the same query string appended to it. (Note that a Campaign-level Tracking Template can be overridden at the Adgroup-, Ad-, or Sitelink-level, so those more specific Tracking Templates would have to not be used for a Campaign-level Tracking Template to be used.)

Resources