TextFinder StartFrom() not working correctly - javascript

I've been trying to tackle a small line of code for some time now, with no luck.
I have a text finder, which I need to start from the 3rd column (C)
var textFinder = responses.createTextFinder(tdate); var search_row = textFinder.startFrom(3).findNext().getRow();
I've also tried
textFinder.startFrom('C').findNext().getRow()
and
textFinder.startFrom(1,3,responses.getLastRow()).findNext().getRow()
Any help would be greatly appreciated, all I need is to get the row number of tdate - searched in column 3

startFrom(range) accepts range as the only argument. You can get a range from sheet or spreadsheet
textFinder.startFrom(responses.getRange('C1')).findNext().getRow()
Note that search starts from "C1" , but not restricted to column C.
Related Answer

Related

How do I give an autoresize function greater than 26?

If you set a value greater than 26 for the autoresize function, an error will occur. "Exception: Those columns are out of bounds." How to fix it?
Updated answer:
You said you have 96 columns. Most likely, you are not referencing to the correct sheet. Because 26 is the default number of columns when you create a new sheet. Make sure you refer to the correct sheet. You can use getSheetByName("Sheet1") and replace Sheet1 with the name of your sheet.
Just add more columns in the sheet or reduce that number
you don't have 26 columns available in your sheet:
if you use autoResizeColumn(columnPosition) make sure columnPosition exists in the sheet.
you don't have 26 columns after the starting specified column:
if you use autoResizeColumns(startColumn, numColumns) make sure you have numColumns after startColumn

Auto-increment dates in two cells if date has passed

Overview:
I'm not a programmer but I managed to get some serious coding into a Gsheets to track my teams project, so we have multiple-variable dropdown menus and integration with google calendar to track projects development and all that.
Why I'm at stackoverflow:
I kind of lack the knowledge to start the code from the scratch, I usually find spare parts of code through forums on the internet and clue them together and it usually works surprisingly well, but this time I couldn't find much informtation.
What I need:
I have 5 cells, and we can put as below,
Date start - Date end - date code* - number** - Priority***
*script to add the date range to gcalendar
** & *** The number is an array that's based on the word written on the priority cell, for example: If priority is written Weekly them
the number colunm will show 7 on the cell to the left and them it
goes. (monthly = 30 and blablabla...)
So I'd like to know if someone could give a hand with a script that would work (at least in my head) as following:
If I set the priority to weekly, it will show 7 on the number colunm and them, every time the "Date end" has passed, it will automatically add 7 days to the "Date start" and "Date end" again.
That way I could keep the projects on a loop where I'll be able to track them constatly.
Thanks in advance for any insights provided,
ps: I've seen some posts about this on sql, but I have no idea also on how to take advantage of the proposals that were presented there.
Edit:
Spreadsheet picture
eDIT2:
Spreadsheet with a increment colunm
Pertinent to the data set and description, you probably do not need any VBA as the increment could be achieved by adding +1 to the reference pointing to previous cell. For example, assuming cell A1 is formatted as Date, enter in cell B1: =A1+1 , then in cell C1: =B1+1 and so on. The result should be as shown below
A B C
9/1/2017 9/2/2017 9/3/2017
It could be further extended with simple logic allowing do display incremented value only if the previous cell is not empty, like : =IF(A1,A1+1,"")
In your case, it could be cell F1 containing =IF(E1,E1+1,"").
FYI, the underlying value of Date is just an Integer value (Time is represented as decimal part), so the arithmetic operations could be applied.
More generic solution would be based on the Excel DATE() Worksheet formula as shown in sample shown below (adding 1 mo. to the date entered in cell A1):
=DATE(YEAR(A1), MONTH(A1)+1, DAY(A1))
In order to implement additional logic, you may consider using Excel Worksheet IF() statement like for example, cell B1 containing:
=A1+IF(C1="week",7,1)
A B C
9/1/2017 9/8/2017 week
so based on the IF() condition it will add either 7 days if C1 contains the word "week" or 1 day otherwise. It could be further extended with nested IF().
Hope this will help.

Search with multiple range values on same item

I'm implementing a search filter via instantsearch.js with a range slider.
The slider filters a range of years based on the year data column of each item. In this DB tho there are some items with no precise year, but a "supposed" period, like "circa XVIII sec" or "End of 1910s". This means that for these items there is not a single year to filter but rather multiple years.
Let's say for ex. that I wish to filter results in a range of years from 1874 to 1930 and I have an item with "Second half 19th century" in the year field. As you can tell it should result in the match, since any year from 1851 to 1900 is correct for this item.
How should I treat this type of data to be part of this filter range?
How should I structure the data in the year column of this DB?
Should I use some script logic in the algolia javascript search rather than use a special way of structuring the data or indexing?
I was thinking of a logic like:
"If value of item is not just digits, convert it to a range of years.
Then check if the range of these years can match with the filter required in
the slider"
I can't really tell how to do this, and it looks a bit cumbersome and silly to me. I'm pretty sure this is no new issue to face in DB data design, so there has to be a proper way to address it.
I tried searching around but I don't even know how to proper word this thing I'm asking.. if you have suggestions to edit the title please do tell me!
I'm using a MySQL database along with PHP.
With Algolia, you'll need to convert this values to timestamp then you would be able to use numericFilter and add a range slider or numeric refinement list component to your UI.
Also the attribute must be defined as an attributesForFaceting in your index configuration.
https://community.algolia.com/instantsearch.js/documentation/#rangeslider
https://community.algolia.com/instantsearch.js/documentation/#numericrefinementlist
Considering your year as a range, you can either add a beggining and an end attribute to those fields. Example:
EventTimes
id SMALLINT NOT NULL PRIMARY,
yearEnd DATETIME,
yearStart DATETIME
In this case, the end and the start will be equal (I use null ends), when the event is an specific time, and becomes a range when the two fields are filled.
When SELECTing, you can always check for both fields, without a significant loss of speed or accuracy. Then check either for specific time, range of times, or if an event begins, ends, re-begins, re-ends and so on, you can check for different fields within the same table.

Map markers become inaccurate when past accumulation of 10 properties

I forked an interesting map application with sidebar information for a different purpose.
However, I noticed today that every time I go past 10 parklets from this repository:
http://mick.github.io/jekyllmap/ or (https://github.com/mick/jekyllmap), it starts getting slightly wonky.
I've poked around in mapping.js from assets/js to see where the problem may be coming from.
I can't figure out where it is coming from.
The markers in my application, when past 10 parklets, the markers get stuck, don't change color, or point to the wrong info.
Any advice on how to get this to work for about 26 properties?
Thanks!
ps.to make it clear, the links above are not my github accounts. figured it would be simpler to link to the original account from which i forked from.
mapping.js line 7
var point = parseInt($(this).attr('data-target').substr(1));
or
var point = parseInt($(this).attr('data-target').substring(1));
and not
var point = parseInt($(this).attr('data-target').substr(1,1));
Edit:
Sorry no need to use substring instead of substr. Just delete second parameter.
As said in substr doc : str.substr(start[, length])
If you set the second parameter .substr(1,1)
The string return is from character 1 (the second in the string as the index starts at 0) for a length of 1.
For #1 and #10 or #11 .substr(1,1) returns 1.
If you don't pass the second parameter .substr(1) you get the original string from character string[0] to the end of the string.
For #1 .substr(1) returns 1.
For #100 .substr(1) returns 100.
For #19298298928 .substr(1) returns 19298298928.
And if you're curious difference between substr and substring is here

Best way to search a row in google spreadsheet

So, been looking at search functions in google spreadsheet, and find it difficult to figure out a smooth way to find which column on row one contain a specific value.
To explain a bit more, its a simple allocation spreadsheet, basically who works as what on which project for how long, and as we have a number of different pipelines, I wanted the pipelines separated. So I created a sheet for each, set up the first five collumns so contain all kind of useful info (like resource, project, project role, chargeable, client) then the rest of the collumns represents weeks, so each collumn have the date of the Monday, and all eight sheets have the same setup, so column 6 to 28 contains the date of the following Monday, allowing me to predict resource allocation a total of 22 weeks or thereabouts.
The next step is to create a report (sheet 1) which tells me by resource how busy they are, either as summary or as detailed+summary, and put some colour in if anyone is allocated to many or to few days in a specific week.
I also wanted to view to allow me to specify a date, easy enough, two drop down menus. First is the list of dates row one sheet two, second one is the same list, so the user can in specify 27/01/2014 - 03/04/2014 from the drop down list.
Now comes my issue, I want to retrieve the numerical value of the columns matching the date, so if the start date is in column F I want a variable with 6 in. And end date is in M thats 14.
Anyone have any good suggestions how this can be done?
Tried reading the row and searching it as an array, did not work particularly well
var vcSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Office");
var range = vcSheet.getRange(1,1,1,28);
var dates = range.getValue();
var strCol = dates.indexOf(dtStart);
var stpCol = dates.indexOf('Task');
Browser.msgBox('Found start col on ' + strCol + ' end col on ' + stpCol);
Have you tried .getValues(), as opposed to .getValue()? Maybe something like;
var dates=range.getValues();
for (i in dates[0]) {
if (dates[0][i].indexOf(dtStart)>-1) { some stuff }
}

Categories

Resources