We have a custom button to update a lookup field if it's blank on the button click. I'm using flow to update the actual value. However, when 2 users click on the button at same time, the 2nd click overrides the value, whereas we would expect the alert to show up. It works as expected if the 2nd user refreshes the page first. How can I make the code work to make sure it works all time?
{!REQUIRESCRIPT('/soap/ajax/54.0/connection.js')}
location.reload();
if('{!Audit__c.Audit_Contact__c}' == ''){
location.replace(‘—flow URL---')
}
else{
alert("The OMA Audit Contact is already assigned.");
}