Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)
Answered

Updating Vendor Address using X++

(0) ShareShare
ReportReport
Posted on by 2,426

Good Morning,

I am trying to update Vendor Address only State Field for all vendors through excel

not through DMF(Because i want to update Tax information also for every vendor)

Can i achieve his through DMF or X++ ?

Which tables should i update.

I am really Confused.

Please help.

Regards.

Have  a great day.

*This post is locked for comments

  • Verified answer
    AX 2012 r3 Profile Picture
    2,426 on at
    RE: Updating Vendor Address using X++

    And to update Address .

    Because i have updated through form.when state is changed.then Address is also changing.

    So,Update Address also

    Please use this piece of code.

    postalAddress.Address = LogisticsPostalAddress::formatAddress(postalAddress.Street,postalAddress.ZipCode,postalAddress.City,postalAddress.CountryRegionId,postalAddress.State,postalAddress.County,postalAddress.DistrictName,postalAddress.StreetNumber,postalAddress.BuildingCompliment,postalAddress.PostBox);

    Regards

    Have a great day.

  • Verified answer
    AX 2012 r3 Profile Picture
    2,426 on at
    RE: Updating Vendor Address using X++

    Hi Chaitanya,

    Thank you so much for reply.

    we can update logisticpostal address.state.

    This piece of code will do

    //To Update
    VendTable vendtable;
    LogisticsPostalAddress postalAddress;
    DirPartyLocation partyLocation;
    EffectiveDateTime fromdate;
    ExpirationDateTime todate;
    ttsBegin;
    select firstFast vendtable where vendtable.AccountNum == "INMF-000001";

    select forUpdate firstOnly postalAddress
    exists join partyLocation
    where partyLocation.Location == postalAddress.Location
    && partyLocation.IsPrimary == true
    && partyLocation.Party == vendtable.Party;
    postalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
    postalAddress.State = "Andhra";
    postalAddress.ValidFrom = DateTimeUtil::getSystemDateTime();
    postalAddress.ValidTo = DateTimeUtil::maxValue();
    postalAddress.doUpdate();
    ttsCommit;
    info("Updated");

    Relation :-

    Vendtable ==  vendtable::find("INMF-000001");

    vendtable.party == dirpartylocation.party;

    dirpartylocation.location == logisticspostaladdress.location //Here u will get Multiple Records whether primary and not primary records .Update based on condition.If all need to be updated Use while here

    //Upto here it is updated succesfully.

    //Go and check in view whether it is updated or not.We didnot update View in code.But it is updated.

    //The relation continues

    Logisticspostaladdress.recid == dirpartypostaladdressview._recid_logisticspostaladdress //Here it is updated Automatically.No need to update in View.

     

     

    If i am wrong.Please correct.

    Regards.

    Have a great day.

  • Suggested answer
    Ajit Profile Picture
    8,755 on at
    RE: Updating Vendor Address using X++

    I believe it would be good to use the view instead of using multiple joins if possible.

    We can get recid of LogisticsPostalAddress from that view using party and 'IsPrimary' checkbox and then select the buffer of that table and update the state.

  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: Updating Vendor Address using X++

    Hi,

    Vendor address state value can be retrieved from tables VendTable, DirPartyTable, DirPartyLocation, LogisticsLocation and LogisticsPostalAddress (or) through the view DirPartyPostalAddressView(mentioned in the blogs suggested by Vilmos)

    You can use the following job(query) to get the data and to update the state:
    static void VendorState(Args _args)
    {
    VendTable vendTable;
    DirPartyTable dirPartyTable;
    DirPartyLocation dirPartyLocation;
    LogisticsLocation logisticsLocation;
    LogisticsPostalAddress logisticsPostalAddress;
    LogisticsAddressState LogisticsAddressState;

    while select vendTable
    where vendTable.AccountNum == "Vend1" // Vendor
    join dirPartyTable
    where vendTable.Party == dirPartyTable.RecId
    join dirPartyLocation
    where dirPartyLocation.Party == dirPartyTable.RecId
    && dirPartyLocation.IsPostalAddress == true
    //&& dirPartyLocation.IsPrimary == true // To get primary address
    join logisticsLocation
    where logisticsLocation.RecId == dirPartyLocation.Location
    && logisticsLocation.Description == "AddressDescription" // Address description
    join logisticsPostalAddress
    where logisticsPostalAddress.Location == dirPartyLocation.Location
    {
    // Older state
    info(strFmt("State: %1", logisticsPostalAddress.State));

    // Newer state - Check on the new state
    if (LogisticsAddressState::exist(logisticsPostalAddress.CountryRegionId, "NewState"))
    {
    ttsBegin;
    logisticsPostalAddress.selectForUpdate(true);
    logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
    logisticsPostalAddress.State = "NewState";
    logisticsPostalAddress.update();
    ttsCommit;
    }
    }

    }

    Hope this helps you.

    Thanks,
    Chaitanya Golla

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Updating Vendor Address using X++

    Hi,

    New GST is calculating on State code.

    So,They want to change State for all vendors.

    Regards.

  • Vilmos Kintera Profile Picture
    46,149 on at
    RE: Updating Vendor Address using X++

    I am unsure what you are doing, but what is needed for updating or creating address or any other contact information is via the view mentioned in the articles.

  • AX 2012 r3 Profile Picture
    2,426 on at
    RE: Updating Vendor Address using X++

    Hi Vilmos,

    Thanks for your quick reply,

    i have seen this blog.

    i am updating.So i am searching for updating.

    i am searching how state is achieved first

    i.e through Vendtable.PostalAddress().state;

    So i will go backwards and will see postaladdress() and i will update as according to that.

    Suggest me if i am Wrong.

    Regards.

    Have a great day Vilmos.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Kempeth Profile Picture

Kempeth 4

#1
Andy Adamak Profile Picture

Andy Adamak 4

#1
Community Member Profile Picture

Community Member 4

Featured topics

Product updates

Dynamics 365 release plans