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)

Add Old ItemId in Field when Triggered Alternate Item

(0) ShareShare
ReportReport
Posted on by

In Sales Order Lines, I add an Item and Yes the Alternative Item Prompt. (The Alternative Item will replace the Old Item).

Not I added a Field in SalesLine named "OldItemId", i need to put the OldItemId that is replaced by the Alternative Item.

How can i do it? / Which method should i put the code? 

thanks.

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,386 Super User 2025 Season 2 on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    Hi RenSonozaki,

    On the SalesLine table there is a method called ItemIdModified (not checked if this is the real name).

    You can add your logic here.

  • Community Member Profile Picture
    on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    Hi Andre, can i ask which method or line triggers or calls the alternative class? icant seem to find it in itemidmodified. thanks for the answer too.

  • André Arnaud de Calavon Profile Picture
    299,386 Super User 2025 Season 2 on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    The method name I referred to is called ItemIdChanged. So it was almost correct. In any case you can fill the OldItemId or do you want to have this field only filled when it is actually replaced with an alternative?

  • Community Member Profile Picture
    on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    yes, i only want the field to be filled when it is replaced with an alternative item.

    i can't seem to do it,

    i tried to modify the ItemIdChanged,

    i tried to modify the setAlternativeItem method in SalesLine,

    but the olditemid field becomes empty after changing the item into alternative.

    mind if you can give me some more tips or code to do it? thanks.

  • André Arnaud de Calavon Profile Picture
    299,386 Super User 2025 Season 2 on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    What code did you try to add?

    The setAlternativeItem would be the best place I guess.

    After the line "This.ItemId = itemId;

    You add the next statement:

     this.OLDItemId             = itemIdOrig;

  • Community Member Profile Picture
    on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    i have tried that and also tried putting it after     this.itemIdChanged();

    but the olditemid becomes blank after i click yes in the Change to AlternativeId prompt.

  • André Arnaud de Calavon Profile Picture
    299,386 Super User 2025 Season 2 on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    Have you actually checked what is really going on using the debugger? Also when running business logic in CIL, make sure yooou have run an incremental CIL.

  • Community Member Profile Picture
    on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    yes, the item resets on this.itemIdChanged(); resulting to clear all the fields

    i also put the code after this.itemIdChanged(); but i have the same result.

    i dont know what to do next, i've been trying all i know. thanks for suggestions.

  • Verified answer
    Sohaib Cheema Profile Picture
    48,813 User Group Leader on at
    RE: Add Old ItemId in Field when Triggered Alternate Item

    Hi,

    this is happening on below location

    \Data Dictionary\Tables\SalesLine\Methods\createAlternativeItem

    kindly put your code in this method

    after below line of code put your code

    this.setAlternativeItem(salesAlternativeItem);

    this.YourCustomziedField = origItem;

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
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans