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

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

Solution (Verified) This post has 1 verified solution | 7 Replies | 2 Followers

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
hagi posted on 2012-9-13 16:55

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

Solution (Verified) Verified Solution

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
Solution (Verified) hagi replied on 2012-9-14 21:16
Verified by hagi

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;

}

All Replies

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
hagi replied on 2012-9-14 15:12

Anyone?

Male
2,087 Posts
33,967 Points
Joined: 2003-1-21
Last Online:
2013-6-17 18:17
Location: Herts, England
DynamicsAXMVP
Moderator
Harish Mohanbabu replied on 2012-9-14 15:27

Hi Hagi,

Sounds like customization might be needed.

Harish Mohanbabu
Long way to go before I sleep ..

View Harish Mohanbabu's profile on LinkedIn

Male
253 Posts
5,015 Points
Joined: 2009-6-17
Last Online:
2013-5-2 13:41
Location: Aarau, Switzerland
Janis Cehovs replied on 2012-9-14 17:33

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")

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

8) 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.

9) Print the confirmation and enjoy.

 

Janis.

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
hagi replied on 2012-9-14 19:54

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?

 

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
hagi replied on 2012-9-14 20:14

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

Male
253 Posts
5,015 Points
Joined: 2009-6-17
Last Online:
2013-5-2 13:41
Location: Aarau, Switzerland
Janis Cehovs replied on 2012-9-14 20:22

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.

21 Posts
255 Points
Joined: 2012-3-7
Last Online:
2012-9-19 22:34
Location: uk
Solution (Verified) hagi replied on 2012-9-14 21:16
Verified by hagi

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;

}

Page 1 of 1 (8 items) | Get this RSS feed | Bookmark and Share