Linking objects using the API

I want to link membership contributions to the invoice that included the membership payment. I do not use the Dolibarr GUI system for creating neither member, thirdparty, membership, or the invoice. I use the API.

If I use the Dolibarr GUI and create an invoice then I get a link and in the invoice it is reported like this:

  "linkedObjectsIds": {
    "subscription": {
      "509": "49"
    }
  }

(there is no link in the subscription json, but the GUI does have it.).

Checking the previous invoice who is totally unrelated I see a decremented number 508

  "linkedObjectsIds": {
    "commande": {
      "508": "542"
    }
  }

and for another invoice decrement I get a different number 505.

  "linkedObjectsIds": {
    "commande": {
      "505": "498"
    }
  }

These linked object numbers, 509, 508, 505 does look like they are unique and they do look like they are just a simple autoincrement in a database table, but is that so?

What happens if I use the same number several places?

How can I find the next available number using the API?

I created my own linking code in Python that use the database directly because I couldn’t find an API endpoint in version 14

If you want I can share it here so you can get a better understanding of how it works :grinning:

I ended up making it possible using the API and have submitted it in a pull request which was accepted, I just don’t know when it will actually be making it’s way into a release, maybe 20?