Thank you to all responder to this questions.
However, when I tried my code again after 2 days, my previous issue resolved itself.
This is my code
function AddRecord() {
const ItrCell = FormWs.getRange("F18")
for (var i = 1; i <= NumOfCopyIndus; i++) {
ItrCell.setValue(i)
const FieldVals = DataRangeIndus.map(f => FormWs.getRange(f).getValue())
FieldVals.unshift(NextIDIndus)
const TimeSp = SettingsWs.getRange("A16").getValue()
FieldVals.unshift(TimeSp)
//console.log (FieldVals)
IndustrialLogsWs.appendRow(FieldVals)
}
//copy picture to first row data
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName("User 1 Form"), true)
spreadsheet.getRange('D16:D18').activate();
spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Industrial Fishing Logs'), true);
var DestCell = SettingsWs.getRange("B2").getValue() - i + 2
var tmp = "O" + DestCell
console.log(tmp)
spreadsheet.getRange(tmp).activate();
spreadsheet.getRange('\'User 1 Form\'!D16:D18').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, true);
spreadsheet.getRange('O7').activate();
}
Maybe because there is false reference in my previous code.
FYI, I just realize that we should not interrupt append line
IndustrialLogsWs.appendRow(FieldVals)
While it is in the process of appending multiple rows. That's why I put the codes to copy image from form after the loop.
I use sheet to save the lastrow value so that I can access it to know to which row I should paste the image in cells.
Hopefully this code works well when multiple user do save data at the same time from different form to same table.