web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to update delivery address while creating a Sales order using X++ code

(0) ShareShare
ReportReport
Posted on by 530

Hi,

I am creating Sales order using X++ code and inserting values into SalesTable and SalesLine table. 
How to automatically populate Delivery Address in sales order? 
Which tables to look into for delivery address of a customer and what relations to follow?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    5400 Profile Picture
    7,162 on at
    RE: How to update delivery address while creating a Sales order using X++ code

    You have to cerate postal address through API  and same recid you have to mapped in DeliveryPostalAddress field in saleatble.

    you can use below API \Classes\DMFLogisticsAddressHelper\generatePostalAddressGlobal to create SO address.

    Note: Default address will come from customer address as postal address. if you want override you can use above API for same.

    For more info

    stackoverflow.com/.../set-deliveryname-and-deliveryaddress-in-a-sales-order-header-and-lines-ax-2012

  • Suggested answer
    Sohaib Cheema Profile Picture
    48,972 User Group Leader on at
    RE: How to update delivery address while creating a Sales order using X++ code

    I hope you called following line of code

    .initFromCustTable

    see below how it goes it standard AX

    initFromCustTable >> initFromCustTableServer >> initFromCustTableIL >> initFromCustTableMandatoryFields

    and then following code is used

    CustTable               custTable  = this.custTable_CustAccount();
        DirPartyTable           partyTable = this.partyTable_CustAccount();
        LogisticsLocation       location;
        LogisticsLocationEntity locationEntity;
    
        this.CustGroup                  = custTable.CustGroup;
    
        location = LogisticsLocationDefault::findSimpleDefault(custTable, LogisticsLocationRole::findBytype(
            LogisticsLocationRoleType::Delivery));
        if (location.RecId)
        {
            locationEntity = LogisticsLocationEntity::constructFromLocationRecId(location.RecId);
            this.DeliveryPostalAddress  = locationEntity.getPostalAddress().RecId;
            this.AddressRefRecId        = custTable.RecId;
            this.AddressRefTableId      = custTable.TableId;
    
            this.setDeliveryName();
        }


  • Mariano Gracia Profile Picture
    on at
    RE: How to update delivery address while creating a Sales order using X++ code

    Soahib has posted a good example that I'm sure it will help you, I also recommend to take a look at LogisticsLocationSelectForm classes, you will understand better how to copy addresses and also it is good to know how it works, may be you will need to modify standard behaviour in the future

  • Verified answer
    Osama Anjum Profile Picture
    530 on at
    RE: How to update delivery address while creating a Sales order using X++ code

    Hi,

    I solved the problem by calling initFromCustTable() method directly into my code just after SalesLine.SalesId=SalesTable.SalesId;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans