I have reduced the occurences of this happening in my app using semaphores. Because I only have one API application this means I can wrap a whole business process in one semaphore and effectively prevent writes from more than one place at once - they just queue up. This seems to have solved the problem without having to query for order numbers. Now, if you have multiple applications running in multiple contexts all calling your TG account you may need to create a front door for TG to do this - basically to act as a dispatcher to control the number of accesses you are making to TG. I’m working in Node at the minute, and am using the semaphore library, but the same would be true in Java using synchronized methods. You need to add your own API call which acts as a gatekeeper to the TG API, and you can then limit access. There are probably other ways of doing it with Apigee or other API gateway technologies.
Also, I’ve found that updating a PO number appears to work, but clearly doesn’t quite update everything because a search for the old number will still bring up both POs, even though in the results the new PO is showing the new number, which is a little odd. It could be a result of search indexes not being updated - I don’t know.
This also means I am only using PO IDs to look up POs now, and not PO numbers. So I have a dropdown list the user selects from (which could have two POs with the same ID but (probably) different suppliers) but the “value” parameter behind it is a PO ID not the PO number.
This combination of things seems to have solved our problem. If you want more technical details / assistance drop me an email on roger AT softfox.com