views:

125

answers:

2

G'day,

OK, I have now rewritten this question totally:

I am trying to import data into Dynamics through the use of the Business Connector (ideally, I would be importing it directly through SQL but I understand that is not a good idea - however I am open to other suggestions). This is to import invoices from a production system into Dynamics / Axapta (v5).

I can code to insert data into the CUSTINVOICETABLE table, which works fine and generates the RECID. However, new invoices just inserted exist without an Invoice ID (until they are posted I understand). However, I need to insert line items into the CUSTINVOICETRANS table as children of the above entry. For this you need to set the INVOICEID field to refer the above as the link to the parent. However, this does not appear possible before the invoice has been posted. Or I may be way off track?

Does anyone have any ideas or can shed any light for me? That would be much appreciated.

Regards, Steve

A: 

Ok, it's actually as easy as it should be.

After the insert statement, simply use the get_Field call:

axRecord.Insert(); recID = (long)axRecord.get_Field("RECID");

You insert the line items in the CUSTINVOICELINE table (which uses a PARENTRECID), then upon posting the items get inserted into the CUSTINVOICETRANS table linked to the appropriate invoice number.

I hope this saves someone from having to work this out themselves.

Steve

MrCraze
A: 

To post a "Free text invoice" simply call custPostInvoiceJob.run() method. You will have have to make the object first, then call a method with your newly created CustInvoiceTable record.

In X++:

custPostInvoiceJob = new CustPostInvoiceJob();
custPostInvoiceJob.updateQueryBuild(custInvoiceTable);
custPostInvoiceJob.run();

You will have to translate that into Business Connector calls in your preferred language.

Jan B. Kjeldsen
Hi Jan,Just wondering what the 'updateQueryBuild' part does - that is a bit I left out.
MrCraze
Look in the code!It updates its query to select your `custInvoiceTable` only.
Jan B. Kjeldsen