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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Customer Address Roles Update

(0) ShareShare
ReportReport
Posted on by 3,732

Hi,

I'm working on the customer address update on the X++. Able to update the address details, but I cannot update the roles in that address. I had mentioned the code which I'm trying.

Code:

LogisticsPostalAddress address;
Custtable custtable;
DirPartyPostalAddressView addressView;
DirParty DirParty;
container roles;

custtable = Custtable::find("902536");
address.Location = 22565428539;
address.CountryRegionId = "USA";
address.State = "NY";
address.Street = "34";
address.ZipCode = "10119";
address.City = "new york";

addressView.Party = CustTable.Party;
addressview.initFromPostalAddress(address);
addressView.locationRoles();

DirParty = DirParty::constructFromPartyRecId(CustTable.Party);
roles = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId];
DirParty.createOrUpdatePostalAddress(addressView, roles);

If I add the "address.Location = 22565428539;" means it update the address but it didn't update role detail. Can you give me the solution for it!!!

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,075 Super User 2025 Season 2 on at

    Hi Sathish,

    I'm not quite sure what is working or not. You are using a hardcoded value for the address.location field.

    Perhaps you can have a look in the class DMFLogisticsAddressHelper for some guidance. This class is used for several Data Import/Export Framework entities to create or update addresses also with roles.

  • Suggested answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    The relation between customer locations and location roles is stored in DirPartyLocationRole table.

  • Sathish Sivakumar Profile Picture
    3,732 on at

    Hi Guys,

    Have you ever worked on updating the customer address with roles (Delivery, invoice, business, etc,.) on X++. If you, please share some code please.

  • Andrew Xu Profile Picture
    3,877 on at

    Are you going to update the role of an address or update the address of a specifice role of a customer?

  • Sathish Sivakumar Profile Picture
    3,732 on at

    Hi, 

    I am going to update the roles in the address.

  • Suggested answer
    Andrew Xu Profile Picture
    3,877 on at

    Hi Sathish,

    Try this,

    static void ChangeCustAddressRole(Args _args)
    {
    CustTable custTable;
    DirPartyLocation dirPartyLocation;
    DirPartyLocationRole dirPartyLocationRole;
    LogisticsLocationRoleType oldRoleType, newRoleType;
    LogisticsLocationRole logisticsLocationRole;
    ;

    custTable = CustTable::find(Your Customer Account);

    select forUpdate firstonly dirPartyLocationRole
    exists join dirPartyLocation join logisticsLocationRole
    where dirPartyLocation.Party == custTable.Party &&
    dirPartyLocation.IsPostalAddress == NoYes::Yes &&
    dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId &&
    dirPartyLocationRole.LocationRole == logisticsLocationRole.RecId &&
    logisticsLocationRole.Name == enum2Value(Existing LogisticsLocationRoleType);

    ttsBegin;
    dirPartyLocationRole.LocationRole = LogisticsLocationRole::findBytype(New LogisticsLocationRoleType).RecId;
    dirPartyLocationRole.update();
    ttsCommit;

    info('change is done');
    }

  • Sathish Sivakumar Profile Picture
    3,732 on at

    Hi Andrew Xu,


    Your code works perfectly, but I need to update multiple roles means what should I do?

  • Suggested answer
    Andrew Xu Profile Picture
    3,877 on at

    You have 2 options,

    1. Manually execute the code with your customers/roles.

    2. Write a loop to execte the change. Refer to http://msdn.microsoft.com/EN-US/library/aa892768.aspx, see how to write a loop in X++.

  • Suggested answer
    Umer Ejaz Profile Picture
    230 on at

    Try updating roles using addEntityLocation method from DirPartyLocation table. in roles you could potentially send multiple roles RecIds and force the roles replacement.

    roles = [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Invoice).RecId,

                  LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Delivery).RecId];

    dirPartyLocation.addEntityLocation(roles, true);

  • Community Member Profile Picture
    on at

    Select * From LogisticsLocationRole

    --Delievery Address (5637144577)

    update dirpartylocationrole 

    set LOCATIONROLE = 5637144577

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans