Best way to get Invoicing Address on Sales Confirm Report (AX 2012)

Hi. I would like to add the invoicing address field to the sales confirmation report in AX 2012. I do not want to create the whole logic from scratch. I was wondering if there is an easy way to get this field. Thanks

Anyone?

Hi Hagi,

Sounds like customization might be needed.

Hi,

the easy way is:

  1. create a new field in the temporary table “SalesConfirmHeaderTmp”. Create a field called, let’s say, InvoicingAddress with an EDT type Addressing.

  2. modify the class method SalesConfirmDP.setSalesConfirmHeaderTmp() by adding a new line somewhere in the top part: salesConfirmHeaderTmp.InvoicingAddress = CustTable::find(custConfirmJour.InvoiceAccount).address();

  3. Open the Visual Studio project for this report: AOT → Visual Studio Project → Dynamics AX Model Projects → SalesConfirmReport

  4. In Visual Studio window expand the Datasets and right-click on SalesConfirmHeaderDS, click option “Refresh”. After refresh, expand this data source and check the “Fields” section if the InvoicingAddress field has appeared in the list. If not, your Visual Studio hasn’t been started with the right configuration.

  5. After you have confirmed that the data source has the reference to the InvoicingAddress field, expand Designs section of the report, click “Edit Using Designer…” on the node “Report”.

  6. As the report opens in design mode, from the Toolbox drag a Text Field element onto your design in the place where you would like to see the invoicing address on the confirmation document. Then right-click on that field, choose option “Expression” and type in:

=First(Fields!InvoicingAddress.Value, “SalesConfirmHeaderDS”)

  1. That’s it, save everything. Deploy the report (from Visual Studio or from AX AOT).

  2. Restart the SSRS instance. You might need this to force the dictionary update on SSRS side since you updated the data definition for data source.

  3. Print the confirmation and enjoy.

Janis.

Hi Janis. Thank you for your answer. What if there is no invoice account for that customer? There are three scenarios:

  1. Customer has Invoice account (use the invoice address if it exists otherwise use delivery)

  2. Use the regular Customer ACCount (use the invoice address it exists otherwise delivery)

you think the method considers these?

Also, this method only gets the address that is specified as ‘primary’

Hi,

well, the method considers invoice account which has been originally entered in Sales quotation or Sales order (Sales Order and Sales Quotation both have a field called “Invoice account”, the value is then later transferred to confirmation and invoice). Normally you wouldn’t look up for customer’s invoicing account while printing the confirmation, as the report is supposed to print journalised values. If the invoicing account is going to be different from order account, then this should be clearly stated in quotation/order by entering the InvoiceAccount for the quotation/order.

The only additional logic you could implement here is that you don’t print any invoicing address if such has not been found OR you could print the main postal address of the OrderAccount if there is no InvoiceAccount entered. In this case in step 2 you would write a code like this:

if (custConfirmJour.InvoiceAccount) // if there is an invoice account specified in confirmation

salesConfirmHeaderTmp.InvoicingAddress = CustTable::find(custConfirmJour.InvoiceAccount).address();

else // no invoice account specified, use default postal address

salesConfirmHeaderTmp.InvoicingAddress = CustTable::find(custConfirmJour.OrderAccount).postalAddress();

Janis.

I think this would work better. Thanks!

display Addressing InvoicingAddress()

{

Addressing address;

DirPartyRecId party;

party = CustTable::find(custConfirmJour.InvoiceAccount).Party;

address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Invoice);

if (!address)

address = DirParty::getPostalAddressByType(party, LogisticsLocationRoleType::Delivery);

return address;

}

Better yet, CustTable has a method called invoiceAddress that encapsulates most of the logic above.