How to prevent the same record from being updated at the same time
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-17-2024 04:41 AM
I found Simultaneous Update Alert script my instance:
// Warn when two users are editing the same record
function onSubmit() {
var updatedOn = gel('onLoad_sys_updated_on').value;
if (!updatedOn)
return;
var gr = new GlideRecord(g_form.getTableName());
if (!gr.get(g_form.getUniqueValue()))
return;
var dbUpdatedOn = gr.sys_updated_on + '';
var dbUpdatedBy = gr.sys_updated_by + '';
if (updatedOn != dbUpdatedOn)
return confirm(new GwtMessage().getMessage("{0} updated this record since you opened it - overwrite with your changes? Additional comments and Work notes will not be overwritten.", dbUpdatedBy));
}
Based the above, it will submit, when user select yes in confirm message.
I don't want to submit, so I changed this script like the following, but it did not worked.
Even if I pushed update button, it didn't happen anything. In other word, I can't save the record.
// Warn when two users are editing the same record
function onSubmit() {
var updatedOn = gel('onLoad_sys_updated_on').value;
if (!updatedOn)
return;
var gr = new GlideRecord(g_form.getTableName());
if (!gr.get(g_form.getUniqueValue()))
return;
var dbUpdatedOn = gr.sys_updated_on + '';
var dbUpdatedBy = gr.sys_updated_by + '';
if (updatedOn != dbUpdatedOn)
confirm(new GwtMessage().getMessage("{0} updated this record since you opened it - overwrite with your changes? Additional comments and Work notes will not be overwritten.", dbUpdatedBy));
return false;
}
What should I do for it?

- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-17-2024 06:12 AM
return false;
In the last line of your script is not letting the form submit. Remove this line and the form will start submitting.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
01-17-2024 06:31 AM - 編集済み 01-17-2024 06:34 AM
My explanation was not enough.
When this script is run, I will not be able to submit in all cases (even if I am the only one who has opened the record).
Also,confirm message did not show. I could not understand that reason.