Unique Business Key

Hello all Camundos

Camunda 7.9 CE full distribution

I need advice on how to go about ensuring a unique BK. Currently I’m maintaining a csv file with previous BK’s on the …/apache/webapps/ path. On the embedded Start form, I have an input field asking the user to provide a BK. I also use a XMLHttpRequest to access the csv file and bring all of it’s content into a JavaScript variable. I then use JavaScript to check if the BK has been used previously. If the BK has been used, I prompt the user to enter a different BK and check it again. If not found, I allow the process to start with the provided BK. A JavaScript End Execution Listener on the Start event (server-side code) then appends the new BK to the csv file.

However, not being a developer, I sense this is not the best solution. Reasons: 1 all the csv data is downloaded to the browser (client-side) 2 : the search happens on the browser.
Surely I can simply call a function on the server-side, passing the csv file name and the BK as parameters, to check if the BK has been used before and then return just a Boolean to the client? But I have no idea as to how to do that! Can the external task help in this regard? I presume not. So how can I improve on the current solution? Or is how I’m currently doing it the best solution? Is it even possible to call a function on the server-side other than creating my own REST service etc?

Thanks for reading this far

Would this help? i.e. adding the constraint back into the DB to enforce a unique business key

https://docs.camunda.org/manual/7.5/user-guide/process-engine/database/#business-key

Thanks for your response @steve

I’ll look into adding it back into the DB.

However as a matter of interest, is it possible to call a back-end script from the browser (embedded Start or UserTask form), and have it return a response to the browser?

Much appreciated