Examples of CoC Extensions.

      In Ax7 we cant directly customize source code. For that Microsoft has intoduced CoC extensions 

I,e Chain of command extensions.

 By Using Coc we can extend any element in AOT and customize as per our requiremnts.

Here some of the examples for CoC extensions.




[Extensionof(formDataSourceStr(LedgerJournalTransDaily,LedgerJournalTrans))]

public final class LedgerJournalTrans_Extension

{

void initValue()

{


FormDataSource fds = this;

LedgerJournalTable ledgerJournalTableloc;

LedgerJournalTrans ledgerJournalTransloc = fds.cursor();

FormRun formrun;

next initValue();



Args args = new Args();


formrun = element.args().caller();

ledgerJournalTableloc =formrun.dataSource().cursor() as LedgerJournalTable;

Info(ledgerJournalTableloc.JournalNum);

ledgerJournalTransloc.InvoiceNum = ledgerJournalTableloc.JournalNum;

//InvoiceNum.text(ledgerJournalTableloc.JournalNum);

}


}


formdatafield extension :



[ExtensionOF(formdatafieldstr(LedgerJournalTransDaily,LedgerJournalTrans,ledgerdimension))]

public final  class PMELedgerJournalTransAccNumModified_Extension

{

 public void modified()

    {

        LedgerJournalName   ledgerJournalNamelocal ;

        Ledgerjournaltrans   ledgerJournalTrans ;

        formdataobject fdobj = any2object(this) as formdataobject;


        next modified();

        ledgerJournalTrans = fdobj.datasource().cursor();

        LedgerJournalTable ledgerjournaltableloc = element.args().record();

        ledgerJournalNamelocal  = LedgerJournalName::find(ledgerjournaltableloc.JournalName);

        if(ledgerJournalNamelocal.PMECrijAutoGen == NoYes::Yes)

       {

           ledgerJournalTrans.Invoice = ledgerJournalTrans.PMEGetInvoiceNum(ledgerJournalTrans.ledgerdimension,ledgerjournaltableloc.JournalNum);

            info(ledgerJournalTrans.Invoice);


       }


    }

}





No comments:

Post a Comment