Is it possible groovy scripts access identityService?

I’m trying access identityService by a groovy script but I’ve got a nullpointerexception.
Is it intentional? Or it’s due to security once someone could, by script, create users, delete uses and so on?

Script:
import org.flowable.engine.impl.context.Context

def identityService = Context.getProcessEngineConfiguration().getIdentityService()
def newUser = identityService.newUser("new.user")

I’m assuming you’re using this script in a scriptTask?

I’ve tried it quickly here with this:

<scriptTask id="test" scriptFormat="groovy">
      <script>
      import org.flowable.engine.impl.context.Context

    def identityService = Context.getProcessEngineConfiguration().getIdentityService()
    def newUser = identityService.newUser("new.user")
    out:println newUser
      </script>
    </scriptTask>

And I see in the log that the new user is created:

org.flowable.idm.engine.impl.persistence.entity.UserEntityImpl@2fab4aff

Can you add some more details/stacktrace/etc. on how you’re using this?

Thanks Joram,

The script:

https://intranet.mpgo.mp.br/share/s/vucpZuZMRze3KNN-DUutkw

And the stack trace:

https://intranet.mpgo.mp.br/share/s/G09Alwf4Rom5HBRGHmc_Kg

Debugging, the problem is:

On IdentityServiceImpl.java (ln 48):
public User newUser(String userId) {
return processEngineConfiguration.getIdmIdentityService().newUser(userId);
}

ProcessEngineConfigurationImpl.java (ln 2223):
public IdmIdentityService getIdmIdentityService() {
return idmIdentityService; ***(idmIdentityService is null)
}

How did you configure the process engine?
If getIdmIdentityService() is null, this means that the idm engine is not initialized, which should be the default.
Do you have a unit test that demonstrates the problem?

I’ve just downloaded the last master version, built, ran, created the process (start->scriptTask->end), created the app and start the process.
I’ve used only the web interface.
I’m not configuring the process engine directly or by any unit test.
Could be the version?
Please, What version do you using to test?

Best regards,

Hello Carlos,

i’ve the same problem.
Did you have found a solution?

Thank’s.