Skip to main content

Notifications

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
  • 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 
     
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,934 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.
  • Dodi Profile Picture
    Dodi 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
    Martin Dráb 230,934 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.
  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 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.
  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 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.
     
  • Suggested answer
    Dodi Profile Picture
    Dodi 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
    GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans