Correct the script for Apps Script
The existing script does not write data into an already created row with a date and with each new report in Telegram, it creates a new row with a date that has already been created by the first report. Reports are sent to the Telegram group by different employees. A screenshot of the table is attached.
The principle of the script: when a message arrives in the group regarding reports, the data from it is transferred to the Google spreadsheet; at the same time, the script determines from the message which tab to send the data to and in which column. If there is data in the cell in the required column and in the row with the already created date, then new data should not be inserted there.
It needs to be fixed so that a new row is not created if a row with the date has already been created. And data should be added to the row with the already created date if the cells are empty.
The script itself:
const TOKEN = "xxxxxxxxxx";
const SPREADSHEET_ID = "xxxxxxxxxx";
/**
* Search for a row with a date or create a new one
*/
function findOrCreateRow(sheet, dateStr) {
const [targetDay, targetMonth] = dateStr.split(".").map(Number);
// Get ALL values from column A
const lastRow = sheet.getLastRow();
if (lastRow > 0) {
const displayValues = sheet.getRange(1, 1, lastRow, 1).getDisplayValues();
for (let i = 0; i < displayValues.length; i++) {
const cellText = displayValues[i][0];
if (!cellText) continue;
const parts = cellText.split(".");
if (parts.length < 2) continue;
const day = parseInt(parts[0]);
const month = parseInt(parts[1]);
if (day === targetDay && month === targetMonth) {
Logger.log("Row found: " + (i + 1));
return i + 1;
}
}
}
// If the date is not found — create a new one
const currentYear = new Date().getFullYear();
const newDate = new Date(currentYear, targetMonth - 1, targetDay);
const newRow = sheet.getLastRow() + 1; // GET CURRENT lastRow
sheet.getRange(newRow, 1)
.setValue(newDate)
.setNumberFormat("dd.MM.yyyy");
SpreadsheetApp.flush();
Logger.log("New row created: " + newRow);
return newRow;
}
Applications 1
Client's review of cooperation with Ihor Symchuk
Correct the script for Apps ScriptEverything was understood. I figured it out, got into it, and did it as it should be. Thank you!
Freelancer's review of cooperation with Andrey Vernidub
Correct the script for Apps ScriptThank you! I enjoyed collaborating!
-
12593 600 0 Good day, I have written many scripts for Google Spreadsheet, I work with Apps Script. I will fix the functionality. Feel free to contact me!
-
1798 18 0 Good day, I am ready to take on the task. I will do it quickly and efficiently. I will be happy to collaborate.
-
10123 117 0 Hello.
I have experience with Apps Script. I am ready to take it on. Write to me, we will discuss.
-
2380 8 0 Hello, I am ready to take on your project immediately and complete it quickly and efficiently, feel free to contact me, I have experience with apps script.
-
1168 7 0 I understand the task. Currently, the script for Apps Script creates a new row for each report submission, even if the date already exists — this leads to duplication. The logic needs to be corrected so that when the date matches, the existing row is used, and data is only written to empty columns without overwriting.
I will fix the `findOrCreateRow` function so that it correctly searches for a row by date, considering the format `dd.MM`, and does not create duplicates. I will also ensure that new data is added to the same rows if they are not yet filled in the required columns. It is important that the current year is taken into account, but the date is only specified as day and month — which means avoiding errors during comparison.
I have experience working with Google Apps Script, automating processes through Telegram bots, integrating messages into Google Sheets, and processing data without duplication. I have already implemented similar scenarios for teams where multiple users submit reports, and the system aggregates them into a single row.
The corrected script will work reliably, taking into account all conditions: searching for an existing date, preventing the creation of new rows, and correctly adding data to the appropriate columns without overwriting.
Current freelance projects in the category Javascript and Typescript
Fix the CSS/DOM layout of cards in the Chrome extension for localizing D&D BeyondThere is a Chrome extension Manifest V3 that localizes the D&D Beyond website into Ukrainian. The project is written in TypeScript + WXT. The extension works through a content script: it finds English text on D&D Beyond pages and replaces it with the Ukrainian translation. The… HTML & CSS, Javascript and Typescript ∙ 9 hours 2 minutes back ∙ 21 proposals |
Modules for a website on Laravel
90 USD
Delivery and payment module for the site https://novabook.top/ (Botble CMS / Laravel) Add convenient delivery and payment methods (including installment plans) in the checkout, similar in style and convenience to the mirson ua site.Delivery (mandatory) Nova Poshta Branch… Javascript and Typescript, PHP ∙ 15 hours 5 minutes back ∙ 18 proposals |
Development of the AM Mobility platform (car service, parking, insurance, car rental)
5770 USD
We are looking for a team or an experienced Full Stack developer to create the MVP of the AM Mobility platform. AM Mobility is a unified digital ecosystem for motorists, combining in one application and web platform: parking; car service; tire fitting; car wash; car rental;… Javascript and Typescript, Web Programming ∙ 18 hours 3 minutes back ∙ 83 proposals |
Gsap animations
22 USD
Good day. Corrections need to be made in the current project. A specialist is needed who works well with gsap/lenis. Animation of cards needs to be done. Detailed specifications here:… Javascript and Typescript, Web Programming ∙ 23 hours 48 minutes back ∙ 17 proposals |
Commercial on-premise video communication platform "ViM"It is required to develop an on-premise video conferencing system with a basic calculation for 100 simultaneous connections (10 isolated rooms of 10 people each). The platform should have a built-in architecture for future horizontal scaling up to 1000 users by adding new media… Javascript and Typescript, Web Programming ∙ 1 day 19 hours back ∙ 28 proposals |