Is there a way to automatically click on a task ID?

Is there a way to automatically click on an existing task ID without clicking the mouse in BPMN ?
Hope to get help, thank you very much (sorry my english is not good)

What do you want to achieve? If it’s about selecting a shape of known id, check out this forum answer: Focus, selection e zoom at element - #2 by santosguilherme

I tried running the below code but it just focus, it doesn’t fire the click event @barmac

    let taskId = this.bpmnjs.get('elementRegistry').get('Task_06e1kkf');
    this.bpmnjs.get('selection').select(taskId);

Once I have the id I want it to automatically click and call the click event without using the mouse
Looking forward to your help

And what do you need the click event for? Why do you want to fake it?

Once I have an id, I want to do a click to execute the command by that id instead of having to find the right task to click.

And what command do you want to execute?

For further assistance, please share a CodeSandbox that reproduces your issue in a way that we can inspect it.

I want to execute command

bpmnJS.on(‘element.click’, (event) => {
alert(‘show id’)
});

I have created a code box, when i fill in an available id, when run it focus and click on that task id to show the alert

Thank you !

I am still not quite sure what your use case is. Anyway, the clicked element ID is available via the event. Have a look at this: bpmn-js Sandbox (forked) - CodeSandbox

Thanks for your help !!
Is there a way I don’t need to click on the task (the task knows the id), but it still auto-click on the task with that id?

Please explain me the use case. What do you want to do in your project?

Sorry for the slow response,
autoClickTask

  1. I enter the task id in the input then press enter
  2. It will auto focus and click on that task id and execute click event (not need the mouse to click)
    Sorry my English is not good

OK, and what should be the outcome of the click event?

I want it to display an alert or execute a command defined in the event click

bpmnJS.on(‘element.click’, function(event) {
// do something
});

How about if you execute your command in the code where you listen to the input events? I don’t quite get it why a programmatic click event is required in your use case.

I want when focus is on it can do click command so I can show its extension

bpmnJS.on(‘element.click’, function(event) {
console.log(element.businessObject.extensionElements;)
});

Is there any other way to get its event without having to call the click event ?

Given you know the element’s id, you can get it from the element registry. Then, you can look up its properties directly.

const element = elementRegistry.get(id);
console.log(element.businessObject.extensionElements);

Thank you very much, this solution worked for me

1 Like