List plan item instances by query property involvedUser or involvedUserGroup

Hello Team,

Can anyone please help me for one issue.
I am trying to fetch list of plan item instances based on user or group and for that I need to fetch list of IdentityLink like this.
List list = runtime.getIdentityLinksForPlanItemInstance(planItemInstance.getId());

But above list is empty and I think I need to setIdentityLinks for plan item instances, so I tried to set that information using following code snippet.

IdentityLinkUtil.createPlanItemInstanceIdentityLink(instance, “USERNAME”, “USERGROUP”, IdentityLinkType.CANDIDATE);
But, above call is giving me NPE (Null pointer) and stack trance is like this.

Trance:
java.lang.NullPointerException
at org.flowable.cmmn.engine.impl.util.CommandContextUtil.getIdentityLinkServiceConfiguration(CommandContextUtil.java:384)
at org.flowable.cmmn.engine.impl.util.CommandContextUtil.getIdentityLinkService(CommandContextUtil.java:393)
at org.flowable.cmmn.engine.impl.util.CommandContextUtil.getIdentityLinkService(CommandContextUtil.java:389)

Could you please provide me the best way to do this and share some example?

Regards,
Ron

You would need to call the code above from within a ‘command context’. I.e. you can wrap it in a managementService#executeCommand() call with your own Command.