XppPrePostArgs in AX D365O

Hi,

XppPrePostArgs Class
The XppPrePostArgs class provides information about a publisher's arguments and return values for pre-handlers and post-handlers.

XppPrePostArgs.getThis Method
Gets the publisher's "this" reference.
Returns a nullNothingnullptrunita null reference (Nothing in Visual Basic) reference if the publisher is static.

XppPrePostArgs.getArgNum
Retrieves the ;publisher's argument by index.
The index range is 0-based for static publishers but 1-based for instance publishers.

Sample POST Event Handler for findItemPriceAgreement in PriceDisc Class

 /// <summary>
    ///
    /// </summary>
    /// <param name="args"></param>
    [PostHandlerFor(classStr(PriceDisc), staticMethodStr(PriceDisc, findItemPriceAgreement))]
    public static container PriceDisc_Post_findItemPriceAgreement(XppPrePostArgs args)
    {
        PriceDisc       priceDisc;
        ModuleInventPurchSales  _moduleType=args.getArgNum(0); //The index range is 0-based for static publishers but 1-based for instance publishers.

        ItemId                  _itemId=args.getArgNum(1);
        InventDim               _inventDim=args.getArgNum(2);
        UnitOfMeasureSymbol     _unitID=args.getArgNum(3);
        TransDate               _priceDate=args.getArgNum(4);
        Qty                     _qty=args.getArgNum(5);
        CustVendAC              _accountId=args.getArgNum(6);
        CurrencyCode            _currency=args.getArgNum(7);
        PriceGroupId            _priceGroupId=args.getArgNum(8);

//Any Code

}

XppPrePostArgs.getArg Method 
Retrieves the publisher's argument by name.
Another Sample for Any Field Id from purchline Table methods
Argument names are case insensitive.
public static void modifiedField_Post(XppPrePostArgs _args)
{
    FieldId         fieldId         = _args.getArg('_fieldId'); // Field id refers all fields here so pass this to //swith case and play around
    PurchLine       purchLine       = _args.getThis();

    switch (fieldId)
    {
        case fieldNum(PurchLine, CustTemperature):
          //Any Code
            break;
        case fieldNum(PurchLine, CustQty):
          //Any Code
           break;
     
     }
}

Reference

Reference


 // <summary>
// GET and SET Return values in XPPPrePOSTArgs
    // </summary>
    ///// <param name="args"></param>
    [PostHandlerFor(classStr(AxSalesLine), methodStr(AxSalesLine, priceDisc_Price))]
    public static void AxSalesLine_Post_priceDisc_Price(XppPrePostArgs args)
    {
        AxSalesLine         axSalesLine    = args.getThis();
        PriceDisc_Price     priceDisc_price = args.getReturnValue();

        priceDisc_price = axSalesLine._priceDisc_Price(priceDisc_price);

        args.setReturnValue(priceDisc_price);

    }

Comments

Post a Comment