〇Xpages部(データバインド箇所抜粋)
<xp:
this
.data>
<xp:dominoDocument
var
=
"document1"
formName=
"FormTest"
action=
"openDocument"
computeWithForm=
"onsave"
concurrencyMode=
"exception"
>
</xp:dominoDocument>
</xp:
---------------------------------------------
〇SSJS部(文書保存処理)
function
testConflict(){
try
{
//エラーメッセージ用
viewScope.errorMsg =
""
;
//保存時競合の場合は例外発生( currentDocumentのconcurrencyMode="exception")
document1.save();
}
catch
(e){
// エラー内容で競合かどうか判別
message = @Implode(e.message);
if
(@Contains(message,
"Document has been saved by another user - Save has been cancelled"
)){
"競合が発生しました。"
print(
"error:"
+e)
同じ文書を複数人で編集する事が多いケースで、競合文書を作成したくない場合に有効な処理です。
XPage部のデータバインド部分で concurrencyModeプロパティの値を"exception"に設定する。 上記を設定することで、文書保存時(NotesXspDocument)に競合が発生する場合は例外が発生します。 その例外をtry,catchでcatchします。 エラー内容を確認して競合かどうかをチェックします。