Creating Sales Invoice from Transfer Receipts

Hi there… I am trying to create a Sales Invoice from a posted Transfer Receipt. I have created a new field in the Transfer Order to capture the Customer No. which will then be passed on to the Transfer Receipt. I used the Copy Document Management as a reference to create my own codeunit. I was hoping I could use the CreateToHeader to create the Sales Invoice automatically from the Transfer Receipt. However I’ve not managed to find codes in the standard Navision that automatically creates a document from another document via Copy Document Management. I have placed the following code to create the Sales Invoice after the Transfer Receipt was created: CopyTransRcptDoc.SetProperties(TRUE,TRUE,FALSE); CopyTransRcptDoc.CopySalesInvDoc (TransHeaderReceieved.“No.”,SalesInvHeader); FORM.RUN(43,SalesInvHeader); The parameters for Setproperties are IncludeHeader, CreateToHeader, CreateToLines. However it creates a Sales Quote header instead of to Sales Invoice. I’ve tried using SetView and it still creates it as a Sales Quote. If I use SetRange, it will prompt an error stating that I cannot write to the table. If anyone could help me figure out how I could make the Sales Header to point to the document type Invoice so that my code can create the document from Transfer Receipt, I would be ever so grateful. My second problem is once the code to Create the Sales Header has been completed, it will call the function to copy the Sales Lines from the Transfer Receipt Lines. However at this point the system will prompt me an error stating that Sell-To Customer is not assigned to the Sales Header. But I have already copied the Customer No. from the new Cust No. field in my Transfer Receipt header. Help!! In a nutshell, everytime the Sales Document is created, it is created as a Sales Quote instead of a Sales Invoice and I also cannot proceed to copy the sales line automatically. I’m also open to other ways I should write my code to achieve this. Regards, Ally

Hi Ally, the Sales Quote gets created, because this is the default type for Sales Documents. If you want to change this, you have to code this in the function, where you initialize the new Invoice: SalesInvHeader.“Document Type” := SalesInvHeader.“Document Type”::Invoice; Hope this helps you with the first part of your problem. Daniel

Hi daniel… Thanks :smiley: I did try that yesterday and it now creates a Sales Invoice… Didnt realise it just required that one line… and to think I was wrecking my brains with SetView and SetRange. Ally