I am setting up a sheet where a person will be able to check a checkbox, in different times, depending on the progress of a task. So, there are 5 checkboxes per row, for a number of different tasks.
Now, the idea is that, when you check one of those checkboxes, a message builds up in the few next cells coming after. So, the message is built in 3 cells. The first cell is just text, the second one is the date, and the third one is time. Also, those cells have 5 paragraphs each (one per checkbox).
The problem comes when I try to make that timestamp stay as it was when it was entered. As it is right now, the time changes every time I update any part of the Google Sheet.
I set u my formulas as follows:
For the text message:
=IF($C4=TRUE,"Insert text 1 here","")&CHAR(10)&IF($E4=TRUE, "Insert text here","")&CHAR(10)&IF($G4=TRUE, "Insert text 3 here","")&CHAR(10)&IF($I4=TRUE, "Insert text 4 here,"")&CHAR(10)&IF($K4=TRUE, "Insert text 5 here","")
For the date:
=IF($C4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($E4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($G4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($I4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")&CHAR(10)&IF($K4=TRUE,(TEXT(NOW(),"mmm dd yyyy")),"")
And for the time:
=IF($C4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($E4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($G4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($I4=TRUE,(TEXT(NOW(),"HH:mm")),"")&CHAR(10)&IF($K4=TRUE,(TEXT(NOW(),"HH:mm")),"")
And it all looks like this:
I would appreciate it greatly if anyone could help me get this to work so that date and time are inserted after checking those boxes and they donĀ“t change again
Notice that your struggle with the continuous changing date time. I had the same struggle as yours over the year, and I found a solution that works for my case nicely. But it needs to be a little more "dirty work" with Apps Script
Some background for my case:
I have multiple sheets in the spreadsheet to run and generate the
timestamp
I want to skip my first sheet without running to generate timestamp
in it
I want every edit, even if each value that I paste from Excel to
generate timestamp
I want the timestamp to be individual, each row have their own
timestamp precise to every second
I don't want a total refresh of the entire sheet timestamp when I am
editing any other row
I have a column that is a MUST FILL value to justify whether the
timestamp needs to be generated for that particular row
I want to specify my timestamp on a dedicated column only
function timestamp() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const totalSheet = ss.getSheets();
for (let a=1; a<totalSheet.length; a++) {
let sheet = ss.getSheets()[a];
let range = sheet.getDataRange();
let values = range.getValues();
function autoCount() {
let rowCount;
for (let i = 0; i < values.length; i++) {
rowCount = i
if (values[i][0] === '') {
break;
}
}
return rowCount
}
rowNum = autoCount()
for(let j=1; j<rowNum+1; j++){
if (sheet.getRange(j+1,7).getValue() === '') {
sheet.getRange(j+1,7).setValue(new Date()).setNumberFormat("yyyy-MM-dd hh:mm:ss");
}
}
}
}
Explanation
First, I made a const totalSheet with getSheets() and run it
with a for loop. That is to identify the total number of sheets
inside that spreadsheet. Take note, in here, I made let a=1;
supposed all JavaScript the same, starts with 0, value 1 is to
skip the first sheet and run on the second sheet onwards
then, you will notice a function let sheet = ss.getSheets()[a]
inside the loop. Take note, it is not supposed to use const if
your value inside the variable is constantly changing, so use
let instead will work fine.
then, you will see a function autoCount(). That is to make a for
loop to count the number of rows that have values edited in it. The
if (values[i][0] === '') is to navigate the script to search
through the entire sheet that has value, looking at the row i and
the column 0. Here, the 0 is indicating the first column of the
sheet, and the i is the row of the sheet. Yes, it works like a
json object with panda feeling.
then, you found the number of rows that are edited by running the
autoCount(). Give it a rowNum variable to contain the result.
then, pass that rowNum into a new for loop, and use if (sheeet.getRange(j+1,7).getValue() === '') to determine which row
has not been edited with timestamp. Take note, where the 7 here
indicating the 7th column of the sheet is the place that I want a
timestamp.
inside the for loop, is to setValue with date in a specified
format of ("yyyy-MM-dd hh:mm:ss"). You are free to edit into any
style you like
ohya, do remember to deploy to activate the trigger with event type
as On Change. That is not limiting to edit, but for all kinds of
changes including paste.
Here's a screenshot on how it would look like:
Lastly, please take note on some of my backgrounds before deciding to or not to have the solution to work for your case. Cheers, and happy coding~!
I was wondering how to return the last n entries from a column in Google Sheets.
I have seen how to return the last entry, but say I wanted to return the last 5 entries. What formula is best to use?
You can return the last n entries with the following logic :
=query(Query_formula,"Select * offset "&countif_formula)
You also need to know what your count_formula is. To filter the last n rows you can use this formula :
=countif(B2:B,E2)
This is an example based of the following link's use case :
Filter rows in Google Sheet
I'm trying to show all rows in a jqGrid table. I know I can use rowList to let the user choose how many rows wants to see, but how can I put an option to see all rows? If a put a number like 999999999, it will show all rows because there are less rows, but the user will see that big number as an option and is not too logic.
You can use words instead of numbers in rowList as follows:
rowList:['All','100','500','1000']
Then you have to use your server controller to "convert" that information to a number of rows to show.
I did it like this:
Integer intRows = 0;
if (rows.getClass().equals(String.class) && ((String)rows).equalsIgnoreCase("all")) {
intRows = Integer.MAX_VALUE;
} else {
intRows = Integer.valueOf(rows);
}
So your server will show Integer.MAX_VALUE if user selects "All", or a number of rows it other case.
I think you won't have more than Integer.MAX_VALUE rows in your table, it's such a big number!
In my app, I am using JQGrid to render the data in Grid.
In this case, my Grid is set to loadonce:true and It also provides filter toolbar facility.
My problem is, I am getting wrong count of total number of pages,total number of records and rowNum of the grid when i have used filter toolbar.
For example : My grid is having total 14 records and rowNum = 5. So there are total 3 pages as displayed in below image.
Now the code below works fine for me in normal case (case in which I have not used filters toolbar).
var records = $('#list10').getGridParam('records');
var rowNum = $('#list10').getGridParam('rowNum');
var pageCount = Math.ceil( parseInt(records) / parseInt(rowNum));
But When I used filters the above written code is not giving me updated result. Consider the image below for example ..
Here for this case the above mentioned code gives me same result as .. total pages =3 , total number of rows =14 and rowNum = 5.
Can anyone suggest me that How can I retrieve the updated value of page,total,records,rowNum when I have used filter toolbar ??
I am developing one custom search module in joomla. so I am using joomla's in-built database connection and function.
Problem is that I want to use pagination class in this module but don't know any hint.
Please help me on this.
Thanks.
Step 1: Get the total number of items in your database
ex: select count(*) from #__some_table where ....
Step 2: Import joomla pagination and create pagination object
jimport('joomla.html.pagination');
$pagination = new JPagination($total, $limitstart, $limit);
where
$total = total number of items that you count in step 1
$limit = total number of items you want to display on a page
$limitstart = index of the first item in the page. For example if you have 20 items per page, 0 is start index for 1 page, 20 is start index for second and so on.
Step 3: Show pagination on your page
echo $pagination->getPagesLinks();
echo $pagination->getPagesCounter();