Hi,
Let me explain a bit more detailed, please. I have an import project in D365FO with recurring job for importing of invoices.
I send my invoices in batches via OData interface.
For example, I want to send 2 invoices with lines in one batch:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>2222222-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
</Document>
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICELINEENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICELINEENTITY>
<VENDORINVOICELINEENTITY>
<HEADERREFERENCE>2222222-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICELINEENTITY>
</Document>every header has its line with data. Lines are linked to headers via HEADERREFERENCE. It works, no questions.
Example 2. I want to send invoice "1111111" with data in the line and invoice "2222222" as header only.
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>2222222-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
</Document>
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICELINEENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICELINEENTITY>
</Document>
In this case I don't send any lines for invoice "2222222". It works well. Invoice "2222222" will be created as header only without errors in the log.
Example 3. I want to send 2 header only invoices in the batch:
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>2222222-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
</Document>
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</Document>
In this case D365 throw an error in the log of my job, because there are no lines in the batch.
Thus, at least one line MUST be in the batch.
Question: Is it immutable behavior of D365? May be there is some setting to allow send batches without lines?
Example 4. I want to send 2 header only invoices again, but I've added dummy(empty) line.
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>1111111-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
<VENDORINVOICEHEADERENTITY>
<HEADERREFERENCE>2222222-7f43-4ad7-975d-a3f16055c470</HEADERREFERENCE>
// Data fields
</VENDORINVOICEHEADERENTITY>
</Document>
<?xml version="1.0" encoding="utf-8"?>
<Document xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<VENDORINVOICELINEENTITY>
<HEADERREFERENCE></HEADERREFERENCE>
// Empty data fields
</VENDORINVOICELINEENTITY>
</Document>
In this case D365 creates 2 header only invoices without any errors in the log of my recurring job.
Question: Is it correct way to import header only invoices, when only header only invoice are in the batch?