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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

Event Handler when update inventdim in salesLine dont work d365fo

(0) ShareShare
ReportReport
Posted on by 73
Hallo, can somenody help me?
 
I have to fix when change inventdim in salesLine Table do the calculations
like: sales.SalesPrice = salesLine.xxx_BasePrice + salesLine.xxx_AdjustmentPrice + salesLine.xxx_ShipmentRate
 
 
but my code dont work, need advice to fix it
Thanks you
I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    Event Handler when update inventdim in salesLine dont work d365fo
    Hi Dodi,
     
    I think it's better to add the code at modified event handler at form control level or form DataSource level.
    Adding at table level won't work here, I guess.
     
    Thanks,
    Girish S.
  • Suggested answer
    Dodi Profile Picture
    73 on at
    Event Handler when update inventdim in salesLine dont work d365fo
    Hi Girish,
    Thanks for answer.. but when i check eventhandler in form datasource i cant find onmodified..
    can you help me, how i can find it? btw i new in develop d365fo. need advice. Thanks
     
  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    Event Handler when update inventdim in salesLine dont work d365fo
    Hi, You can check SalesTable form and use onModified event in DataSource fields.
     
  • GirishS Profile Picture
    27,825 Moderator on at
    Event Handler when update inventdim in salesLine dont work d365fo
    You are checking under DataSource level. You need to check the events by expanding the Datasource >> Fields. Refer to the screenshot which Mohit posted.
     
    Thanks,
    Girish S.
  • Martin Dráb Profile Picture
    236,974 Most Valuable Professional on at
    Event Handler when update inventdim in salesLine dont work d365fo
    OnModified would trigger if a user modified InventDimId field through a form control, which will never happen. Users can't do that; they modify fields of InventDim table and the system will then determine InventDimId value and set the value of SalesLine.InventDimId.
     
    If there is no suitable method (handling this logic) to hook to (I would be surprised by that), you can run your code when SalesLine record is being updated.
  • Dodi Profile Picture
    73 on at
    Event Handler when update inventdim in salesLine dont work d365fo
     
    i'm use code like this
     
     
    its work, but i worry there is data that is out of sync between tables because I changed salesline.salesprice. any input?
    Thanks
  • Martin Dráb Profile Picture
    236,974 Most Valuable Professional on at
    Event Handler when update inventdim in salesLine dont work d365fo
    Your approach indeed looks wrong to me.
     
    You have a correct feeling that your code is wrong. You're updating a unit price without recalculating the line amount. Look at logic for SalesPrice in SalesLine.modifyField().
    There is also a deeper problem with your design. You seem to completely ignore F&O pricing logic (base price, trade agreements, sales agreements etc.). Still, you let the system to do all the work to determine the correct price, but then you ignore the result and overwrite the price with one calculated with your simple logic. But that's what you wanted to do, so I focused on the topic of this thread, instead of challenging the whole idea.
     
    Also, I don't think you should be using the Updated event. That's the last resort when there was no suitable method, but SalesLine.modifyInventDim() looks suitable to me. That would be a good place for general logic reacting to changes in InventDim, but in this case, I think you should change the logic determining the unit price.
  • GnaneswaranKrishnaram Profile Picture
    4 on at
    Event Handler when update inventdim in salesLine dont work d365fo
    Hi Dodi,
    As mentioned by Mohit, you may need to write event handler at Field level "OnModified" in the datasource by copying the event handler method which gives you method signature to write your code.
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormDataFieldEventHandler(formDataFieldStr(SalesTable, InventDim, InventColorId), FormDataFieldEventType::Modified)]
    public static void InventColorId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
    // your code goes here      
    }
     
     
     
    Thanks
    Gnaneswaran 
     
     

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 650 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 582 Most Valuable Professional

#3
CU05031448-0 Profile Picture

CU05031448-0 526

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans