See Custom/Extension Property in History

Do custom properties added to a model appear as part of the Activity History entity? I was wishing to add properties to Tasks, etc in the model and use those properties to filter history events in a custom history handler. Maybe I have to take some property of the AcivityInstance History and ‘find’ the custom property?

@Bill_Powell, Extension properties are not persisted in the history tables for any activities in camunda.

Maybe you can add ExecutionListener or TaskListener for the activity and get the BPMNModelInstance of that activity and extract the extension properties of that task and persists as local variables which will have scope for task level.

@Slf4j
@Component
public class LoggerDelegate implements JavaDelegate {
  public void execute(DelegateExecution execution) throws Exception {
    BpmnModelInstance bpmnModelInstance = execution.getBpmnModelInstance();
    Collection<CamundaProperty> extensionProperties = bpmnModelInstance.getModelElementsByType(CamundaProperty.class);
    if (!CollectionUtil.isEmpty(extensionProperties)) {
      Map<String, Object> extensionPropertiesMap = new HashMap<>();
      extensionProperties
          .forEach(property -> extensionPropertiesMap.put(property.getCamundaName(), property.getCamundaValue()));
      execution.setVariablesLocal(extensionPropertiesMap);
    }
  }
}
1 Like

Thanks, I will try that approach.