AX7 - 2/5 SubcribesTo

A continuación vamos a crear un ejemplo que podéis probar para ver el funcionamiento del atributo SubscribesTo.

Vamos a crear un delegate que recibirá por parámetros una custTable; en la misma clase nos crearemos un método el cuál recibirá una Custtable y nos mostrará por pantalla información de ésta.
Cómo se puede ver el método estará ligado al delegate que creamos mediante el Atributo SubscribesTo.

class Test
{
    delegate void getAccountDescription(CustTable   _custTable){}

    public static void main(Args _args)
    {
        test        test = new test();
   
        CustTable   custTable;

        select firstonly custTable;

        test.getAccountDescription(custTable);
    }

    [SubscribesTo(classstr(Test), delegatestr(Test, getAccountDescription))]
    public static void getAccountDescriptionHandler(CustTable _custTable)
    {
        info(strFmt("%1 %2", _custTable.AccountNum, _custTable.name()));
    }
}


Al ejecutarlo podemos ver cómo al llamar al delegado de nuestra clase se disparará el evento.



que ejecutará el método getAccountDescriptionHandler porque está ligado al delegate.



Aquí el resultado final.




Comentarios