I'm designing a warehouse app, and since I'm new, I have a lot of questions. I want the information to come from a Google Spreadsheet consisting of two columns (Warehouse, Kilograms). The first column is composed of two elements: the Warehouse and the Filling Tank, and the second column contains the Kilograms.
In the app, the Source Tank selection consists of two drop-down menus where I first select the warehouse and then the tank. I would like it to show me the kilos from my spreadsheet corresponding to the selected tank when I select both in the text field below.
function doGet(e) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const inputCode = e.parameter.salesCode; // Receive the sales code from the request
let result = "No match found"; // Default message if no match is found
// Get all data in the sheet (assuming data starts from the first row)
const data = sheet.getDataRange().getValues();
// Look for a matching code in column A
for (let i = 0; i < data.length; i++) {
if (data[i][0].trim() === inputCode.trim()) { // Check for match
result = data[i][1]; // Get value from column B of the matched row
break; // Stop after finding the first match
}
}
// Return the result (either the found value or the default message)
return ContentService.createTextOutput(result);
}
Add this code, deploy it. And design when to trigger..
If bith droodown vakue is selected then set web url to script url+?+salescode=join dropdown 1 selected val + one space + drop-down 2 selected valu
GET request
When web got request
Set textbox text = getresponsecontent after checking it is not No Matching found