C. Griffin
C. Griffin

Reputation: 681

Dynamics AX 2009: Add a field to InventJournalTrans, propagate to InventTrans

I need to add an additional field to InventJournalTrans, that after posting will show up in the InventTrans table. The field is a reference column to a record in another table. What method(s) do I need to modify to make this behavior happen?

Currently, I have already added the fields to both tables and modified the Form to allow the user to enter and save the new field. I just can't seem to find the bottom of the rabbit hole on where the actual posting to InventTrans is occurring.

Ideally, it should just be a:

inventTrans.ReasonRefRecId = inventJournalTrans.ReasonRefRecId;

assignment statement before the

inventTrans.insert();

call. Anybody have a clue on where this is at?

Upvotes: 1

Views: 1727

Answers (1)

C. Griffin
C. Griffin

Reputation: 681

The link above does contain the solution -- I have included the code from that page in case that page disappears or no longer becomes available. Thanks to gl00mie for answering on that site and providing this answer.

You should create a new InventMovement method like this:

public MyNewFieldType myNewField()
{
    return MyNewFieldType::DefaultValue; // suppose your new field is an enum
}

Then modify \Classes\InventMovement\initInventTransFromBuffer

void initInventTransFromBuffer(InventTrans _inventTrans, InventMovement _movement_orig)
{
    // ... append this line to the end of whatever else is already in this method
    _inventTrans.MyNewField            = this.myNewField();
}

And finally overload the new method in the InventMov_Journal class:

public MyNewFieldType myNewField()
{
    return inventJournalTrans.MyNewField;
}

Upvotes: 1

Related Questions