Passing Values Between Pre And Post Event Handler Methods In D365 Extensions Next item Credit Suisse CEO focuses...

Passing Values Between Pre And Post Event Handler Methods In D365 Extensions

we got an requirement that we need to populate a noyes dialog when we modify a field, If we give yes that field has to be changed with new value else we need to keep the previous value.

D365 extensions, we can create Pre and Post event handlers, but they are static, so we need a way to pass a value between them.
Best option is to use static field, like it’s done in RunBase extension example.

Here we have created pre and post event handler for SalesQuotationTable’s Modified method.

class DNT_SalesQuotationTableDiscount_Eventhandler
{
private static int preValue;
///

[PreHandlerFor(tableStr(SalesQuotationTable), tableMethodStr(SalesQuotationTable, modifiedField))]
public static void SalesQuotationTable_Pre_modifiedField(XppPrePostArgs args)
{
SalesQuotationTable SalesQuotationTable = args.getThis() as SalesQuotationTable;
switch (args.getArgNum(1))
{
case fieldNum(SalesQuotationTable, LineDiscPercentage):
info(strfmt(” pre %1″,SalesQuotationTable.LineDiscPercentage));
Dal_SalesQuotationTableDiscount_Eventhandler::preValue =
SalesQuotationTable.orig().LineDiscPercentage;
info(strfmt(” pre v%1″,preValue));
break;
}
}


Your Comment

Leave a Reply Now

Your email address will not be published. Required fields are marked *