Skip to main content

Hello--

Was wondering if anyone can give me a hand with this… We essentially want an exact duplicate of the Description (OrderDesc) field that is already on sales order/invoices.

I have created a new field on each entry screen, but am stuck trying to pass the value from the SO to the invoice.

I assume I should override the PrepareInvoice action, but not sure how to actually reference the fields I have created? 

 

I.e. This is as far as I got but i know “  ThisNewInvoice.CustomerSubject = row.CustomerSubject; “ is obviously wrong

 

Any help is appreciated!!

public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{

>PXOverride]
public IEnumerable PrepareInvoice(PXAdapter adapter, Func<PXAdapter, IEnumerable> baseMethod)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);

var row = (SOOrder)e.Row;

ThisNewInvoice.CustomerSubject = row.CustomerSubject;


return baseMethod(adapter); // and then return
}

 

I think you may find that slide deck useful. 

 

Also, you need to know several things:

  1. To access custom field you need to use GetExtension method. See here: https://riptutorial.com/acumatica/example/27596/how-to
  1. In general a Sales Order is not related 1-1 to an invoice. You may have several invoices prepared for the same sales order (e.g. in case of partial shipping) or you can have multiple sales orders  consolidated in one invoice. Or you can have any mix of them. So you need to take that into account when developing that customization.
  2. You don’t really have the access to the Invoice that is created from the PrepareInvoice method. The proper place for such customization is SOInvoiceEntry.InvoiceOrder method. From that method you have the access to both the SO and the invoice. Also, that method is triggered for all the scenarios when the Invoice is created from a Sales Order while PrepareInvoice method only works when you click that button directly on the Sales order screen.

There is also an InvoiceCreated method that gets called after the invoice is created inside the InvoiceOrder method if I recall correctly. 

public void InvoiceCreated(ARInvoice invoice, SOOrder source, InvoiceCreatedDelegate baseMethod)

You can then pull over any info from the source SOOrder to the ARInvoice. 


@mrthanhkhoi  I’m afraid I don't have the code anymore. There are some code snippets in the slides, probably you can use those. 


@dnaumov This is very useful, thanks a lot for sharing it here.


Thank you @dnaumov this looks like it will be really helpful. Going to work through it a bit before closing thread


Hi @Dmitrii Naumov ,

Could you please share source code in the GIT again? 

 


Reply