How to create a Add new user button and send the ID back to the order

In the form order, I created an “add new user” button.

I open the form for creating a new user in the modal and it should automatically close after insert and add a new user in the form_orders.

I managed this in the onAfterInsert event with

sc_commit_trans ();
[order_customer_id] = {customers_id};
sc_redir (form_orders.php, order_customer_id = [order_customer_id], “_parent”);

Now a problem arises when I try to create the next order.

Let’s say the new user ID was 22 and the name was Jon Doe

In each subsequent entry a new order is user 22 - Jon Doe

Where do I make a mistake?
I tried to reset the global variable but it doesn’t work.

Can anyone advise me?

Hi Rik, are you looking for the last instered ID?

Yes. I have now the “select customer” field set like:
SELECT customers_id, customers_name
FROM customers
ORDER BY customers_id DESC

and as soon as the insert new and form for new closes, the user is already on select.
But with that I lost “Use title”
where do I write “Please select customer”