I created an example Form [1] and a Spreadsheet [2] based on your description of the process. I developed the code below to update the highest bid price in the Sheets when a user submits the form, only if the bid price in the response is higher than the current one. For this, I used the documentation on triggers [3], the Form [4] and Spreadsheet [5] services.
You need to run the createOnSubmitTrigger function once to create the trigger that will run the runOnFormSubmit function when a user sends a form response:
function runOnFormSubmit(e) {
//Get Form and Sheet objects
var form = FormApp.openByUrl('Form-URL')
var workbook = SpreadsheetApp.openByUrl('Spreadsheet-URL')
var sheet = workbook.getSheets()[0];
//Get the user's responses for the multiple choice and bid price questions
var formResponse = e.response.getItemResponses();
var lotsResponse = formResponse[0].getResponse();
var bidPrice = formResponse[1].getResponse();
//Use the selected lot name and find its row in the sheet
var selectedLotName = lotsResponse.split(', ')[0];
var textFinder = sheet.getRange(2, 2, sheet.getLastRow()-1, 1).createTextFinder(selectedLotName).matchCase(true).matchEntireCell(true);
var highestBidCell = textFinder.findNext().offset(0, 3);
//If the user's bid price is higher that the the current highest bid, update the sheets
var highestBid = highestBidCell.getValue();
if(bidPrice > highestBid) {
highestBidCell.setValue(bidPrice);
//Get Sheets info in array and remove header
var itemsArray = sheet.getDataRange().getValues();
itemsArray.shift();
//Get multiple choice question
var lotsQuestion = formResponse[0].getItem().asMultipleChoiceItem();
var choicesArray = [];
//Build choices array from updated sheets info
for(var i=0; i<itemsArray.length; i++) {
var lotName = itemsArray[i][1];
var description = itemsArray[i][2];
var reservePrice = itemsArray[i][3];
var highestBid = itemsArray[i][4];
var choiceString = lotName + ', ' + description + ', ' + reservePrice + ', ' + highestBid;
var choice = lotsQuestion.createChoice(choiceString);
choicesArray.push(choice);
}
//Set choices array to the multiple choice question, this will only be done when the bid price is higher that the the current highest bid
lotsQuestion.setChoices(choicesArray);
}
}
//Creates on form submit trigger
function createOnSubmitTrigger() {
var form = FormApp.openByUrl('Form-URL');
ScriptApp.newTrigger('runOnFormSubmit')
.forForm(form)
.onFormSubmit()
.create();
}
To ensure that the script will run only once at the same time, you can use the Lock service [6].
[1] https://docs.google.com/forms/d/e/1FAIpQLSfP4skRoqQSY543wE7UbGMLMR7_glIvWpA-hl1k-kufudN64A/viewform?usp=sf_link
[2] https://docs.google.com/spreadsheets/d/1AaGeODbtm4vybQJqdoXL_3zB7hBwIYHZgcwTvtaaXN8/
[3] https://developers.google.com/apps-script/guides/triggers/events
[4] https://developers.google.com/apps-script/reference/forms/form-app
[5] https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app
[6] https://developers.google.com/apps-script/reference/lock/lock