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)

Mappings used in Methods - AX 2012

(0) ShareShare
ReportReport
Posted on by

Trying to learn how this all relates.  I was looking at the methods in the table InventItemPrice.  The PriceUnit Method looks like the following:

PriceUnit  priceUnit()

{

return this.InventPriceMap::priceUnit();

}

And the following is the Method in the InventPriceMap table.

 

PriceUnit  priceUnit()

{

return this.PriceUnit ? this.PriceUnit : 1;

}

I am trying to make sense of this. 

1)Why is it pulling the priceUnit from InventPriceMap and not from InventItemPrice? 

2)Is it pulling all 3 files mapped into one (it references InventItemPrice, InventItemPriceSim and InventTableModule)

3)When does the Map get populated?

 

I am fairly new to this, so please explain like you would to a 5th grader.  Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Klaas Deforche Profile Picture
    2,433 on at

    Hi :)

    A map is all about reusing business logic. If you have 2 or more different table that have more or less the same fields and some code that does more or less the same for each table, there is a good change that your can use a Map. "Maps vs tables" as a bit similar to "Class vs a class that extends that class" in a way.

    To answer your questions:

    1. It's all about reusing logic, the logic is written on the map so the table just uses that.

    2. No, it is only returning the price for the record that is currently "in" the map.
    You can do this: map = record; This assigns the record to the map, eg: inventPriceMap = inventItemPrice;
    If you then do inventPriceMap.tableId(), it will return the table id of the inventItemPrice table, because the record the map "is" that record in a way :).
    A map is simply an other type that can contain your record (when it is mapped), and will return values for that record.

    3. The following (weird) syntax gets a map object for that table and calls the priceUnit method: this.InventPriceMap::priceUnit();
    It just converts the current record to the type InventPriceMap so in a way it isn't being populated but just assigned. It's just syntax :).

    I hope this is clear :). It's all about reusing code, and creating a map is they way you can use the same code to retrieve data from different tables.

  • Community Member Profile Picture
    on at

    Okay - that is beginning to make more sense.  I appreciate the response!

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