Process Name for each business Key

can i associated processInstanceName for a specific business key ?

so each instance creates businessKey that should have a unique ProcessInstanceName for it can we do that ?

You have full control over what the business key and process instance name will be for a process instance.

What have you tried so far?

Cheers,
Filip

Currently i have just implemented a method which will generate new order Id for each instance and that does display on ProcessEngine on the flowable-ui

@Component
public class CreateBusinessKey implements SubProcessBusinessKeyGenerator {

private int min_range=10000;
private int max_range=1000000;
@Override
public String generateBusinessKey(SubprocessInstanceContext subprocessInstanceContext) {
    StartSubProcessInstanceBeforeContext subProcessInstanceBeforeContext=new StartSubProcessInstanceBeforeContext();
    String parentBusinessKey=subprocessInstanceContext.getBusinessKey();
    int randonNumber=generateRandomeNumber(min_range,max_range);
    Set<Integer> usedKeys=new HashSet<>();
    while (parentBusinessKey.equals(String.valueOf(randonNumber)) || usedKeys.contains(randonNumber)){
        usedKeys.add(randonNumber);
        randonNumber=generateRandomeNumber(min_range,max_range);
    }
    subProcessInstanceBeforeContext.setBusinessKey(String.valueOf(randonNumber));
    subProcessInstanceBeforeContext.setProcessInstanceName("name");
    return String.valueOf(randonNumber);
}
private int generateRandomeNumber(int min_range,int max_range){
    Random random=new Random();
    return min_range+random.nextInt(max_range-min_range);
}

}

So lets say the parentProcessBusinessKey was having 900001 the child instances will be having different business key i want to display the name or we can associate a unique name to each instance

And how are you passing the business key and name to the process instance?

The “Call Activity” has the options you can set to give it the name and business key

image

I have used the property inherity business key = “true” and whenever that happens it will considered callActivity as subprocess and then generate a new businesskey for that processInstance which will use the class StartSubProcessInstanceBeforeContext to set the current ProcessInstance with the new business key generated.

Can we use the Instance Name dynamically to set the name for each new business key but again how?

I don’t understand this. Why are using inherit business key if you want to generate a new one. The StartSubProcessInstanceBeforeContext has the callActivityExecution from which you can get the process instance that is creating the child process instance.

If you are already using StartSubProcessInstanceBeforeContext then you can just set the business key and and process instance name there and then those will be used for the call activity.