I know of a solution using a custom workItemHandler, I'll provide the details below hopefully you can substitute the Script Task with a custom workItemHandler.
A list of VariableInstanceLog objects can be obtained from the AuditLogService for a given processVariable, from each of these audit objects you can access the last modification date.
The logic of your required check can then be implemented in the custom workItemHandler passing the result to the process instance.
Here's a snippet of example of code that will print out the last modification date of a process variable called 'TheResult' in the current process instance.
public class CustomWorkItemHandler extends AbstractWorkItemHandler {
private AuditLogService auditLogService;
public CustomWorkItemHandler(KieSession ksession) {
super(ksession);
}
public void executeWorkItem(WorkItem workItem,
WorkItemManager manager) {
// sample parameters
String sampleParam = (String) workItem.getParameter("SampleParam");
String sampleParamTwo = (String) workItem.getParameter("SampleParamTwo");
// complete workitem impl...
auditLogService = new JPAAuditLogService(getSession().getEnvironment());
//TheResult - is the process variable to check
List<VariableInstanceLog> list = auditLogService.findVariableInstances(workItem.getProcessInstanceId(), "TheResult");
if (list.size() > 0){
VariableInstanceLog log = list.get(list.size()-1);
System.out.println("Last Recorded Date:" + log.getDate());
}
// return results
String sampleResult = "A result to return here";
Map<String, Object> results = new HashMap<String, Object>();
results.put("SampleResult", sampleResult);
manager.completeWorkItem(workItem.getId(), results);
}
@Override
public void abortWorkItem(WorkItem workItem,
WorkItemManager manager) {
// stub
}
}
You will need to add the packaged custom workItemHandler jar as an artifact through Business-Central and register your workItemhandler passing the ksession to the constructor in your project->settings->Deployments->WorkItemHandlers e.g.
HandlerNameHere -- new org.jbpm.contrib.CustomWorkItemHandler(ksession) -- MVEL
More details on building a custom WorkItemHandler, using an maven archetype, can be found here
http://mswiderski.blogspot.com/2018/04/jbpm-work-items-are-really-simple.html
And to incorporate the customWorkItemHandler into your process see this short video
https://www.youtube.com/watch?v=_XIZ0KRTahE