Create user in modeller

I am trying to create user in javascript (inline) of service task in the modeller

This is my content:
var person = new Object();
person.firstName = “John”;
person.lastName = “Doe”;
person.email= “myemail”;
person.password = “secret”;
person.id=“someid”;

execution.getProcessEngine().getIdentityService().saveUser(person);


The error that i get is: Cannot cast jdk.nashorn.internal.scripts.JO to org.camunda.bpm.engine.identity.User

What is wrong with my script

Hi @teja_polisetty,

the Nashorn JavaScript engine is not clever enough to convert the JavaScript object to the Java object of the required Class.

You have to create your Object in a Java like fashion:

var person = new org.camunda.bpm.engine.impl.persistence.entity.UserEntity();

Hope this helps, Ingo

1 Like

@Ingo_Richtsmeier works like a charm, thank you