MultiInstanceActivityBehavior bug?

This image is my bpmn xml

I want to set the assignees through the custom attribute ‘approverType’, so I need to read the current userTask node configuration information, but my code cannot solve this problem

if run code,the method will be enter many times, only first time enter the code block, can read activitiId
so first time can

my test code :

@Component
@Log4j2
public class AutoAssingeeService {

    public List<String> getAssignees(DelegateExecution execution) {
        String activitiId = execution.getCurrentActivityId();
        if (StringUtils.isBlank(activitiId) || !activitiId.contains(BpmnParse.MULTI_INSTANCE_BODY_ID_SUFFIX)) {
            return null;
        }
        activitiId = activitiId.replace(BpmnParse.MULTI_INSTANCE_BODY_ID_SUFFIX, "");

        BpmnModelInstance bpmnModelInstance = execution.getBpmnModelInstance();
        UserTaskImpl userTaskImpl = bpmnModelInstance.getModelElementById(activitiId);
        ExtensionElements extensionElements = userTaskImpl.getExtensionElements();
        Collection<CamundaProperty> properties = extensionElements.getElementsQuery()
                .filterByType(CamundaProperties.class).singleResult().getCamundaProperties();

        if (CollectionUtils.isEmpty(properties)) {
            return null;
        }

        Iterator<CamundaProperty> iterator = properties.iterator();
        while (iterator.hasNext()) {
            CamundaProperty CamundaProperty = iterator.next();
            String approverType = CamundaProperty.getAttributeValue("approverType");
            if (StringUtils.isBlank(approverType)) {
                continue;
            }
            List<String> userList = getAssignUser(CamundaProperty, approverType);
            return userList;
        }
        return null;
    }

    private List<String> getAssignUser(CamundaProperty element, String type) {
        log.info("approver type is : {}", type);
        List<String> userList = new ArrayList<>();
        switch (type) {
            case ActivitiTagConstants.APPROVER_TYPE_COMMON:
                // TODO Need to develop according to actual business
                String userIds = element.getAttributeValue(ActivitiTagConstants.ATTRIBUTE_USER_IDS);
                if (StringUtils.isBlank(userIds)) {
                    userList.add("common1");
                    userList.add("common2");
                } else {
                    userList.addAll(Arrays.asList(userIds.split(",")));
                }
                break;
            case ActivitiTagConstants.APPROVER_TYPE_ORGMANAGER:
                // TODO Need to develop according to actual business
                userList.add("orgManager1");
                userList.add("orgManager2");
                break;
            case ActivitiTagConstants.APPROVER_TYPE_LEADER:
                // TODO Need to develop according to actual business
                userList.add("leader1");
                userList.add("leader2");
                break;
            case ActivitiTagConstants.APPROVER_TYPE_ROLE:
                // TODO Need to develop according to actual business
                userList.add("role1");
                userList.add("role2");
                break;
            default:
                throw new RuntimeException("type error");
        }
        return userList;
    }
}

public class ActivitiTagConstants implements Serializable {
    public static final String ATTRIBUTE_ROLE_ID = "roleId";
    public static final String ATTRIBUTE_ROLE_RANGE = "range";
    public static final String ATTRIBUTE_USER_IDS = "userIds";

    public static final String APPROVER_TYPE_COMMON = "common";
    public static final String APPROVER_TYPE_ORGMANAGER = "orgManager";
    public static final String APPROVER_TYPE_LEADER = "leader";
    public static final String APPROVER_TYPE_ROLE = "role";
}

Hi @jjfjj,

It will be easier to understand the problem if you share a minimal example of your project. You can used this project as a base, fork it and share the github link.

Here are the docs for the multi-instance marker:
https://docs.camunda.org/manual/7.12/reference/bpmn20/tasks/task-markers/

Best regards,
Yana