Skip to Content

Update Business Partner Address

I am having issues updating document addresses.

What I need to do:

I need to ensure that, at the moment when a Document (such as Sales Order, Customer Invoice, Customer Invoice Request) is generated, the Ship From - Ship To Address are validated. The validation process returns a valid address and, my plan is to fix the invalid address in runtime in order to save the correct one.

I am aware that the AddressSnapshot object is readonly once it is saved, so my plan was to make this change BEFORE the AddressSnapshot is saved. However, although the ABSL allows me to update Address fields. changes are never saved!!!!

Specifically, I need to be able to change values such as Postal Code / Region / City Name.

What I have tried:

I have tried to place my code in ALL events from the Extension Object AddressSnapshot

  • Node Root: AfterModify, BeforeSave
  • Node Postal Address: AfterModify, BeforeSave
  • Node Formatted Address: AfterModify, BeforeSave

I have also tried to place my code in the BeforeSave event of the Extension Object Business Partner.

In all cases, as I mentioned before, even though I am able to modify the values BEFORE the object is saved. if I look at the object that is actually saved, I don't see that my changes were taken (I see the old values).

I have also tried to make my validation on the OnSave event of the document where the address is used and I see a message saying that the AddressSnapshot was already saved. I understand that, but, is there any way I could at least generate a new AddressSnapshot?

My final test included a procedure placed in a action of a custom object. I was retrieven the whole Business Partner and then validating the address, but again, I couldn't save my changes.

Is there any way to do this?

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Aug 05, 2020 at 11:09 AM

    Hello Hector,

    I managed to update BP address with this code below, on the before.save of the AP.CRM.Global:SalesOrder

    this.BillToParty.Party.BusinessPartner.AddressInformation.Address.DefaultPostalAddressRepresentation.GetFirst().CityName = "Hector";

    Please, notice this is a quick test and I'm getting the first record just to show you how to get there.

    I added new SO and it updated BP's address:

    However, the SO snapshot still holds the old address information - you may think now on how to update the recently created SO with the updated address.

    HTH,
    Thiago.


    dq4h2.png (430.4 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 06, 2020 at 01:31 AM

    Thank you very much Thiago.

    It worked like a charm.

    I was able to place the same code in the BeforeSave event of the root node in the BusinessPartner object

    Kind regards!

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 24, 2020 at 08:33 AM

    Hector,

    Surely the ship-from and ship-to addresses come from the relevant parties and are thus always valid? If you want to change the address then you should probably just update the various business partners/customers/parties, rather than trying to set an address in the order itself.

    Lewis

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 04, 2020 at 11:54 PM

    Thank you for your response Lewis.

    We assume that an external organism have all the valid addresses.

    I have tried to update the Address at Business Partner level as well but I haven't got good results. Although I am able to modify the values, the updates performed via code ABSL are not saved!

    For instance, If I placed my "changing address" code in the BeforeSave event of the BusinessPartner address. The address is updated but, when I retrieve the BP, my changes are not there.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.