I have a google form link to submit my response that I DONT OWN (think of it as i need to submit my response on this form regularly) sample link here https://docs.google.com/forms/d/e/1FAIpQLSeZfR4Di9yfTDc5yXc7WYmLy-MjwVf_XLC7_ZeQ7367Yh2DpQ/viewform
I need to find the edit URL for the link like this https://docs.google.com/forms/d/1R_Ddx4-BNpnCwRJYQcWxnBJVd0SzvsJDisg2qu41fpU/edit using code.
I DONT want to use any excel etc as i just need to retrieve the editURL. Whats the best way to do it.
When i try below code, it gives me
"Exception: No item with the given ID could be found. Possibly because you have not edited this item or you do not have permission to access it.
I also tried using formID but same issue. Can you help?
function run() {
var form = FormApp.openByUrl('https://docs.google.com/forms/d/e/1FAIpQLSeZfR4Di9yfTDc5yXc7WYmLy-MjwVf_XLC7_ZeQ7367Yh2DpQ/formResponse');
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());
}
You must be an Owner or Editor of the form to be able to get the editURL property of the form using the code you posted.
If you are not an Owner or Editor of this form (or a Super Admin in your Google Workspace Domain), there is no way for you to know the editURL of the form.
Related
the main part of this question relates to how I can define a route in a javascript file. At the same time, I just want to make sure what I am doing is ok. Essentially, on my view page, I can see my records. When I output the records, each row I give
<input type="button" value="Delete" onclick="delete_alert( {{ alert[0].id }} )"/>
This gives the user the option to delete an alert. Before going straight into things, I like to first send it to javascript.
function delete_alert(id){
var answer = confirm("Confirm delete");
if (answer){
$.get("NickAlertBundle_delete", { row: id });
}
}
So if the delete is confirmed, it calls this route
NickAlertBundle_delete:
pattern: /view-alerts
defaults: { _controller: NickAlertBundle:Alert:delete }
requirements:
_method: GET
My first question here is they are deleting the alert from the view-alerts page. Once they confirm deletion, I dont want them to go anywhere, just have the view-alerts page refresh (as this will remove the deleted alert). But is giving the delete route a pattern of view-alerts confusing or wrong to do? Its what I want to do as I want them to stay on this page, just doesnt feel right.
Anyway, my real problem is the error
No route found for GET /NickAlertBundle_delete (from
http://localhost:8000/view-alerts;) (404 Not Found)
So I dont think the way I have define the route in my javascript file is correct. So how can I fix this route?
Thanks
I think you should use an URL as a first parameter to jQuery get. You are currently using the Symfony2 route name, not the URL.
Change it to /alert-views.
OR:
You can add a data attribute to your HTML button that would contain your path, If you are using Twig as templating engine, you can write something like:
data-url={{path('NickAlertBundle_delete')}}
Then using the attr() jQuery function onclick on your button:
var url = $(this).attr('data-url');
Finally, the jQuery get function can be sent to url.
I hope it helps.
So I've got a Google Form where I'd like to pass in a parameter from an email link like this:
https://docs.google.com/URL/forms/d/LONGSTRING/viewform?id=12345
I'd like to be able to grab that id and pass it into the spreadsheet recording results. Now I've got writing to a spreadsheet down, but getting the id is problematic.
I've already tried:
function doGet(e) {
var id = e.parameter.id;
Logger.log(id);
}
and
function doPost(e) {
var id = e.parameter.id;
Logger.log("do post " + id);
}
Both of which throw errors when I view the execution transcript, which I suspect is because they're designed to run within deployed webapps.
Additionally, I've tried using plain old javascript to do something like:
var formUrl = window.location.href;
var formId = formUrl.split('?id=')[1];
which also throws errors when you view the execution transcript .
Any other ideas?? Maybe I can get the information in another way?
I think you can't use your own id, you have to use the id of the Google Form's "Item" object. You can figure out the id by viewing a prefilled form. In the Form edit screen, click "Responses", "Get Pre-filled URL". Fill in the field that you want to use and click Submit. On the new page, you are given a URL in "Share this link to pre-fill the responses" . Examine that url and you can see "get" arguments like ?entry.265525444=mytext . Replace mytext with whatever you want to be in the field.
This will display the field on your form, however. I myself was searching for how to make such a field readonly or invisible when I got here, but I hope this shows you a new direction to try.
I am assuming you are trying to get the form id?
You will need to set up a trigger that will run on form submit.
function onSubmit(){
var form = FormApp.getActiveForm();
var formID = form.getId();
}
I need some advise handling a form submit and page redirect. I have two pages, where the first is a landing page with a simple form, when user select a criteria and submits it, he is redirected to page2 that displays tabular data and some query related info.
When Submiting Page1 Form, data is passed in the url :
for ( var key in dataArray )
{
if ( dataArray[key] )
{
if (queryStr != "")
{
queryStr += "&" ;
}
queryStr += key + "=" + dataArray[key];
}
}
var url = "page2.html?" + queryStr;
window.location.href = url;
On the other hand, I am handling this POST using $_GET['xxx']), then build a query accordingly.The issue is not handling POST & GET requests but handling errors..
I dont like is that if the user types something in the url www.site.com/page2.html?Q1=red -> www.site.com/page2.html?Q1=red545454 it will logically not pass the server side validation and therefore just display an empty page template without data, which kind o bothers me.. Also if the user tries to load page2.html without any posted data(querystring).
I would like upon page2.html load event, check if there are any posted values, if not redirect back.. Is this the correct way of handling it? Thanks
You doesn't submit form through POST method because "on submitting" you usewindow.location.href (redirect) with param Q1 in query string.
If you want see only url like www.site.com/page2.html do next: set action to your form as action="www.site.com/page2.html",instead adding variable to QUERY_STRING dynamically insert Q1 in any hidden element like:
document.getElementById('Q1_ID').value = dataArray[key];
After call like document.forms[0].submit();. Now variable Q1 in $_POST['Q1'] and url look as www.site.com/page2.html.
An elegant way to handle this would be to submit your form using Ajax and respond with validation errors or success message. In case of errors, show them on the current page otherwise redirect user to whatever page you want.
I'm trying to submit a form with Java, which looks like this:
<form id="bForm" action="/a/b.php" method="POST"></form>
There are no <input type="hidden">, there are not even any <input> at all.
In the source, I see that this form is submitted when I click a link which
executes javascript code like this:
javascript:b(<k>,<v>)
where <k> and <v> is some key and value consisting of some numbers.
Now, the function b() in the source is this:
function b(value, key) {
var form = document.getElementById('bForm');
form.action = '/b/user/' + key + '/' + value + '.txt';
form.submit();
}
What I'm trying to receive is the .txt file send as response, but trying to directly open
http://<url>.com/b/user/<key>/<value>.txt
in a browser does not get me the .txt file, but a message saying it has to be accessed by using the POST method.
Now, I read about how to send requests via POST (also from trying to find a
solution here) and think I understood most. Still, I only read about mostly everything today, including what forms are, so excuse me if the solution is obvious.
The problem I have here is that there are no parameters I can pass to "let the URL know" which action to do upon submitting the form.
Now as I can probably not change the action of the form, what do I do?
Can I somehow "connect" to the URL which leads to the .txt file via "POST"?
Or do I need to execute the javascript somehow, and if so how?
Edit: I have solved the problem now, not sure if my explanation was not good enough, but the solution seemed pretty simple, I just didnt know enough about forms.
So, action=#myurl# means that the form is submitted to the #myurl#, not to the current page. And, although the target URL seems to point to some file which cannot do anything with the submitted form, this is not right. In fact, it points to a script, but the script is "hidden" in a way that we only see the path to the file we want to download in the URL.
So, I just did this:
URL url = new URL("http://myurl.com/b/user/" + key + "/" + value + ".txt");
HttpURLConnection c = (HttpURLConnection) url.openConnection();
//set User-Agent, Cookie, etc. properties here
c.setRequestMethod("POST");
c.setInstanceFollowRedirects(false); //not sure if this is needed
InputStream in = c.getInputStream(); //this submits the parameter-less form
//now I can get the response with this stream, i.e. read & save the .txt file
All tested and running complete code now, so it works for sure.
When I use the following link in my browser, a record is populated in the form on this page to edit.
http://vcred.dev/#personal/myacademicdetail?record_id=15
When I click 'SAVE' button, record is successfully updated in database and form with updated values is still in front of me. It is OK for me. But I have only one problem after form is posted. In Address bar URL is still same as before post.
http://vcred.dev/#personal/myacademicdetail?record_id=15
But I want short URL without params in address bar after my form is posted like this:
http://vcred.dev/#personal/myacademicdetail
How it is possible using javascript?
Since you are using a hash in the URL, you could do the following in JavaScript:
location.href = location.protocol + "//" +
location.host +
location.pathname +
location.hash.split('?')[0];
This will not cause a page refresh, as described in this Stack Overflow post: How do I, with javascript, change the URL in the browser without loading the new page?
As far as Zend Framework goes, after you save the record use:
$this->_redirect('#personal/myacademicdetail');
This will tell the user's browser to go to the URL.
I'd do it like this, using PHP:
$referer_host = $_SERVER[ "HTTP_HOST" ];
$referer_uri = explode( "?", $_SERVER[ "REQUEST_URI" ] );
$referer = $referer_host . $referer_uri[ 0 ];
I assumed you might want to see also PHP solution as you've mentioned zend-framework as one of your tags.
I'd simply explode URL like this and then use headers for redirect.