我在Windows上使用带有Case Manager 5.2.1的Java API。
我的网络服务执行以下操作:
// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);
// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();
// Fetch a fresh copy of the case instance
Case cs = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);
// Now set a whole bunch of properties, add documents, etc. etc.
...
// Finally, save all our updates: to "cs", not "newCaseIdentifier"
cs.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
问题:我间歇性地收到此错误:
类的对象{52EECAC2-38B2-4CB5-8F22-BAF33D6C35EC} " MyCaseTypeName"没有更改或删除,因为它被修改 自应用程序检索以来,在存储库中一次或多次 它。更新序列号不匹配;请求USN = 0,数据库USN = 1
我知道只有两个case.save()调用:一个用于" newPendingDocument",另一个用于(#更晚)用于" cs"。
我多次执行 SAME 代码:有时它可以工作,有时如果失败了 "更新序列号不匹配"错误。
问:关于如何解决此问题的任何想法/任何建议?
答案 0 :(得分:1)
查看您提供的代码,我很困惑为什么要创建第二个Case实例。 我想你最好这样做:
// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);
// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();
// Fetch a fresh copy of the case instance (not sure if this is necessary)
newPendingCase = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);
// Now set a whole bunch of properties, add documents, etc. etc.
...
// Finally, save all our updates: to "newPendingCase"
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
我没有与Case Manager合作过,但曾与P8合作过。 api调用非常相似。
USN号码可能有点棘手。如果您正在等待外部呼叫的任何时间段(例如,对于第三方REST接口),您可能希望在呼叫后执行newPendingCase.Refresh()
,然后重新填充案例的任何所需属性。 / p>