@pauline Every time when CreateUser delegate is called in service task, new instance of CreateUser will be created. In your case you marked the class with modifier as “abstract”. In Java, instances will not be created for abstract classes. So please remove the keyword abstract and give a try.
@pauline you are calling nested functions. it wont work like that except anonymous function.
Inside the execute function you are providing implementation of create() function. its wrong implementation. Move all the code which is inside create() function to execute() function.
If you’re not able to do, please upload your java file, i will modify and resend to you.
Hi @pauline,
which camunda version are you using? The execute method from JavaDelegate has only 1 parameter, so you only needs to remove the ProcessEngine paramater from execute method
and get it from delegateExecution variable and finally get the IdentityService this way
public void execute(DelegateExecution execution) throws Exception {
IdentityService identityService = execution.getProcessEngine().getIdentityService();
if(identityService.isReadOnly()) {
return;
}
User singleResult = identityService.createUserQuery().userId("demo").singleResult();
if (singleResult != null) {
return;
}
User user = identityService.newUser("demo");
user.setFirstName("Demo");
user.setLastName("Demo");
user.setPassword("demo");
user.setEmail("demo@camunda.org");
identityService.saveUser(user);
}