Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Data Entity Creation w...
Finance forum
Answered

Data Entity Creation where does the Margin field live?

Posted on by 112
OHello,
 
In D365 F and O I wish to create a Data Entity.  I know how to do this, but I specifically require the Margin field within the Invoice Journal screen.
 
I went into the Form Information screen and can see the Control Name is 'Contribution Margin' and the Data Source is 'CustInvoiceTrans', however, if perform a SQL lookup in this table, there is no ''Contribution Margin' field.
 
Where does the Margin field live or is it calculated on-the-fly?  If so what is the calculation?
 
Thank you,
 
Michael
  • Layan Jwei Profile Picture
    Layan Jwei 3,447 Super User on at
    Data Entity Creation where does the Margin field live?
    Hi Michael,

    There is no such field, could it be a customized field?

  • Verified answer
    Michael Hutcheson Profile Picture
    Michael Hutcheson 112 on at
    Data Entity Creation where does the Margin field live?
    Hi all,
     
    I found what I was looking for - it is this Entity:
     
    Entity:                   Pending and active item prices V3
    Staging Table:      InventItemPriceV3Staging
    Target Entity:        InventItemPriceV3Entity
     
    There is a column within the Entity called [AVERAGEUNITCOST] - this is the cost used to calculated the Margin for Invoiced Order Lines.
  • Layan Jwei Profile Picture
    Layan Jwei 3,447 Super User on at
    Data Entity Creation where does the Margin field live?
    Hi,

    Is your issue question answered? if yes, then please verify the answers that helped.

    Thanks,
    Layan Jweihan
  • Layan Jwei Profile Picture
    Layan Jwei 3,447 Super User on at
    Data Entity Creation where does the Margin field live?
    Hi,

    I don't think it's stored anywhere since it requires calculation.  I just looked at the method and it seems very complex, I don't think computed column would work, you can look at the code inside the display method. So it seems you will need to go with the virtual field  -- and you can see how the performance of the entity will be affected (I mean if it's ok with you or not)



    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Michael Hutcheson Profile Picture
    Michael Hutcheson 112 on at
    Data Entity Creation where does the Margin field live?
    Hi,
     
    Thanks for that, that is a big help.
     
    Is the actual calculation for the Margin field stored anywhere?  I can write T-SQL but how do I know what to replicate?
     
    Regards,
     
    Michael
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 3,447 Super User on at
    Data Entity Creation where does the Margin field live?
    Hi Michael,

    This margin field is a display method in CustInvoiceTrans table. In order to add it to the entity, you will need to use computed columns or virtual fields.

    You can check this link for more details:
    https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/data-entity-computed-columns-virtual-fields


    So you need to look at the logic of this display method, if you can write it in T-SQL then use computed columns. If not then use virtual fields. With virtual fields you can use x++ coding and call the display method but virtual fields cause performance issues that's why we prefer to use computed columns if it's possible to use them

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,623 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,463 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans