I have a PHP script that inserts Quotes for us. The basic procedure is:
- insert Sales Header, get Header Number back (such as '12345')
- insert Sales Lines, using Header Number '12345' as the Document No. Other fields are:
- Line No.
- Type
- No.
- Quantity
- Document Type
- Unit Price
- Line Discount Percent
- Description
This has been active for years and works fine. Today I started a new script that needs to insert Sales Lines onto Orders instead of Quotes. The final insert is literally exactly the same as the Quote insert (using all of the same code), except two fields are different:
- Document No. will be something like 'SO56789'
- Document Type will be 'Order'
Unfortunately this fails every time, with this error:
"The field Document No. of table Sales Line contains a value (SO56789) that cannot be found in the related table (Sales Header)."
Looking at the tables in Nav, the Sales Line table has column 'Document No.' with value 'SO56789' and the Sales Header table has column 'No.' with value 'SO56789'. I can't figure out why it fails. It's worth emphasizing that this works fine as a quote - all code is exactly the same, column names are the same, etc.
Is there some other field I have to pass to insert a line on an Order document?