Google Sheets Apps Script, won't register cell value - javascript

I have a google sheet that uses an app script button to send the values from that sheet to another sheet. If someone forgets to press enter after filling in their information, it will not send the last cell value.
So if the cell previously had the value of 3, then we change it to 4, but don’t press enter, it will send the value of 3.
The solution, I think, is at the beginning of the function for it to submit somehow, or press enter, or select another cell, anything that works. But I can’t figure out how to do that so far.
I’ve tried various things but I can't find the right apps script function.
So far without pressing enter, or clicking on another cell, I am unable to access that cell value. Changing the active selection doesn't work.
const sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("L1");
// change the active selection to another cell, but it just moves the 4 to the new cell
sh.setActiveSelection('A1');

In Google Sheets, it's not possible to force the cell edit submission (a.k. pressing enter) on behalf the active user. If training your spreadsheet users doesn't look a good solution, then you should consider another way for data entry, i.e. make a form in dialog/sidebar so you can use client side HTML/CSS/JavaScript to control your form.

Related

Tracking clicks on a webpage to a google sheet cell

I'd like to be able to track clicks from a webpage to a google sheet via json, how can I increment values on a sheet?
What I'm looking to do is display one of these codes randomly on a page and log copy clicks (there's a button to copy the code via javascript)
How to:
increment the clicks
locate the cell to increment the clicks
Is this something that's possible w/ google sheets?
I just coded a bitly style google sheet web app and show you how to do it here: https://www.youtube.com/watch?v=1SCtkLc-uFQ
in short you get the values from the column of Codes and then you find that index of the clicks column. Then increment by one.

Creating an Extension To Edit Google Doc Spreadsheet

I'm brand new to coding extensions for chrome so I'm hoping someone here can help or point me in the right direction.
I'm looking to create an extension that when you click on it a drop down comes up with 2 text inputs that will allow me to edit a google doc spreadsheet on the fly. Specifically, I'm tracking customer issues for my site and need to continuously add the number of times per day an issue arises.
So in the first text input box I would like to enter #issue click "Track" and it would add a +1 to the corresponding issue's cell within the Google Doc. In the second text input box if I enter #issue2 textdescription and click "create new issue and track" then the function would create a new row describing the issue (text description) and create a rule that from now on when #issue2 is entered in the first "Track" input box then a +1 will be added to that corresponding cell.
I have been able to create a popup box with inputs, however I am having trouble figuring out how to create a function to carry out what I would like to have done to the Google Doc Spreadsheet.
Hopefully, this isn't too wordy :/
Chrome extensions is not the way to go.
Look at google apps script. Use a menu, sidebar or both.

jQuery / Javascript > onClick place text at last known cursor position

I have a form I'm working with that allows the user to continually add new rows as needed (used for making an article with multiple "howto" steps, they can click over and over again to add a new step). What I would like to be able to do is have the user be able to click in any of those rows at any time and then click on a word or button that is off to the side that will then insert the value of that button into the last known cursor position.
So for example I may have one form that currently has 3 rows. If the user goes back and wants to insert some data they could click back in the box and hit the button corresponding to the data they want to insert.
Example input 1: "Remove the customers current IP address and replace with their static IP, [USER COULD CLICK HERE AND THEN CLICK THE STATIC IP BUTTON AND %STATIC_IP% WOULD BE INSERTED AT THE LAST KNOWN CURSOR POSITION (AKA HERE)]
Example input 2: "Enter in the customers [Click to insert %WIFI_SSID%] into the router settings"
I have found several other stackoverflow articles that are able to all insert text but they all expect it to be into a defined textarea or input. In this case I'm needing it to insert into the last known cursor position. I hope this is all clear. I look forward to any assistance or questions.
Starter code: http://jsfiddle.net/4mJwU/
If you already know how to insert some arbitrary content at the last known caret position, your only problem is to know which field was focues last time before button was clicked.
That can be done in numerous number of ways, one of those would be utilize focus and blur events (attached to fields - rows in your case) to track (in some variable for example) reference to the field last focused. It should be a piece of cake from there.
Quick and simple script that can get you started http://jsfiddle.net/sjqWu/1/
Combine what you've learned from other stackoverflow anwsers with example above and you should be ok. Happy learning!
I'd question your design. To make the user have to click a field then click some text to insert into that field seems like too many steps. You could possibly utilize some sort of drag and drop routine. Or instead of the first click being a text box, maybe make it a drop down list?
I agree with WTK. You can store the record id or text box id using some sort of event, then proceed from there.

Custom Autocomplete in Google spreadsheet app

My question is the following, is there any tutorial about how to make that when you begin typing on a google spreadsheet cell, the fields belonging to a custom list that contains (anywhere on the text) the typed characters appears in a drop down list.
I do not know a lot of Javascript, so if there's any book or reference where I can found something similar it would be really appreciated.
I am new, and I don't know of any method for allowing the selection of valid values
to be position based upon what the user starts typing (into a cell).
I know this cannot be done within a script. All scripts run after the user
has made all of their changes (to a cell).
You may already know about a drop-down validation list using defined ranges.
This process puts a small down arrow adjacent to the right-edge of the box.
It allows the user to select from a pre-defined list. It does not prevent
the end user from entering invalid values. It just marks their value as
invalid if it does not agree with one of the entries in the list. And
by pressing the down-arrow, the list of valid values is displayed. The
user can select an entry in the list by clicking on it.
I learned about this validation from the documentation. If that is all you need
then you can stop here.
To me the interesting thing about this validation method is:
you can define the list and give it a name. The invalid error message will include the name. You can use the name to indicate the type of validation error.
The list can be contained on a different sheet other than were it is referenced. The sheet that contains the list can be hidden.
If you add a row to the list area that is not the bottom row, (insert below) the spreadsheet engine will automatically adjust the size of the defined range. The new values entered in the list appear in the updated drop-down list (in the order that they appear in the range definition).
What I have not tested is expanding the list from a script. I don't
know if the spreadsheet engine will perform the same range modification
if the change comes from a script. I would hope that it would.
Also I don't know if you make a changes to a hidden sheet from a script,
then will the hidden sheet remain hidden. I know when you do a "copy sheet"
function from a script, the source sheet is temporarily made current,
and is therefore no longer hidden.
Hope this helps.

Imitating excel sheet with Dojo Grid HELP?

I have a basic web page that I'm trying to capture the enter key when pressed. I will have a page with many rows( depending on what was pulled by the database ) where each field is editable. What I'm trying to do is when a user is focused on a certain column on a certain row, I want them to be able to press enter and their focus will go to the next row but stay in the same column. I'm creating my grid with Dojo Grid.
The first part of the is to figure out how to capture the enter key.
The next part would be to figure out how to bind the javascript function to the paticular field.
Then finally I need to be able to advace my row by 1, stay in the same column and keep my field as editable.
So, any advice on the enter key capturing?
Is this enough? Accessibility Improvements to the 1.3 DataGrid:
Scrolling with the keyboard is now
supported.
Enter key press will now
invoke onrowclick event
When in edit
mode, pressing tab and shift/tab will
move focus to / from other editable
cells in edit mode on the same row
...

Categories

Resources