I have a sheet that you need to select a name from the dropdown and a barcode number then when you click the submit button it should transfer the value of the barcode only to the blank cell beside the name that you selected on the dropdown to another sheet.
Here is my code.
function SubmitLTP1() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
//Collect Data
const sourceRange = ss.getRangeByName("Input_DataLTP1");
const barcode = sourceRange.getValues().flat();
//Gather Current Date & Time
const date = new Date();
const data = [...barcode,date];
//Append Data
const destinationSheet = ss.getSheetByName("Barcode Registration");
destinationSheet.appendRow(data);
//Clear Inputs
sourceRange.clearContent();
ss.toast("Request Submitted!");
}
function onEdit() {
const activeCell = SpreadsheetApp.getActiveSpreadsheet().getActiveCell()
const reference = activeCell.getA1Notation()
const sheetName = activeCell.getSheet().getName()
const activeValue = activeCell.getValue()
if (reference == "B4" && sheetName == "Barcode Registration (LTP1)" && activeValue == true)
{
SubmitLTP1();
activeCell.uncheck();
}
}
Please help me fix it. Thank you so much~