Showing posts with label code insert method d365. Show all posts
Showing posts with label code insert method d365. Show all posts

Tuesday, 26 November 2019

d365 eventhandler insert method table DataEventType::Inserting D365 Code

Below is the event handler code to write at the table level for inserting any value.

  [DataEventHandler(tablestr(FMRentalCharge),DataEventType::Inserting),
   SuppressBPWarningAttribute('BPParameterNotUsed', 'This is not production code')]
   public static void FMRentalChargeInsertingEvent(Common c, DataEventArgs e)
    {
        FMRentalCharge rentalCharge = c;
        FEDiscountEngine discountEngine;

        discountEngine = FMTotalsEngineBase::GetInstance() as FEDiscountEngine;
        if (discountEngine)
        {
            discountEngine.calculateChargeRate(rentalCharge);
        }
    }

FMRentalChargeInsertingEvent -> you can write any name .
SuppressBPWarningAttribute - > is optional( it is for not using the e parameter of the dataeventargs.)

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++  Introduction In our previous posts, we explored what Copilot can do o...