Hello,
The answer is very simple: you should not update a BDM (or create a new one) INSIDE a connector. Only an operation can do that (and you have more operations place than you think: see below).
Understand the concept: a connector is a "sandbox". And a groovy connector is a connector. In the groovy connector (and in any connector call to be clear), you must not change anything in the content. The principle is very clear: keep in mind a connector can be reusable in different processes, so it must not manipulate anything from a process, that's why you have INPUT and OUTPUT in your connector. Only the OUTPUT updates something in the process.
So, your situation, the connector should produce an output, let's say a MAP<String, Object> which is the BDM to create. if (result.get("bdm") is null, you have to create a new one
Map<String,Object> entry = new HashMap<>();
List list = entryDAO.findByDocumentId(document.persistenceId);
if(list.size() > 0){
entry.put("bdm", list.get(0));
} else {
entry.put("creationdate", OffsetDateTime.now());
}
return entry;
Ok, your connector just accesses in READ ONLY.
Now, in the OUTPUT of the connector wizard, you have... operations!
Add an operation
Left operand: a BDM Variable
Right operand, the script
if (result.get("bmd") != null) {
return result.get("bdm");
}
entry = new Entry();
entry.setCreationDate( (OffsetDateTime) result.get("creationDate"));
return entry
Hope this is clear