Friday, September 4, 2020

update method d365 eventhandlertable DataEventType::Updating D365 Code

 Eventhandler code for updating a value at the table level .


[DataEventHandler(tablestr(FMRentalCharge),DataEventType::Updating),
     SuppressBPWarningAttribute('BPParameterNotUsed', 'This is not production code')]

public static void FMRentalChargeUpdatingEvent(Common c, DataEventArgs e)
    {
        FMRentalCharge rentalCharge = c;
        FEDiscountEngine discountEngine;

        if (rentalCharge.orig().PerUnitAmount != rentalCharge.PerUnitAmount ||
            rentalCharge.orig().Quantity != rentalCharge.Quantity)
        {
            discountEngine = FMTotalsEngineBase::GetInstance() as FEDiscountEngine;
            if (discountEngine)
            {
                discountEngine.calculateChargeRate(rentalCharge);
            }
        }
    }

No comments:

Post a Comment