Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

How to use OTB/Custom form datasource methods in extension class in D365FO

$
0
0

Hello,

I have added a new button in Form LedgerJournalTransDaily and in my extension class of the form in the OnClicked event I wanted to use correctedTaxAmount method of the form datasource LedgerJournalTrans.

I couldn't able to achieve it. I don't know where exactly it went wrong. Please guide me on this.

I tried the below code.

[ExtensionOf(FormStr(LedgerJournalTransDaily))]
final class LedgerJournalTransDaily_Extension
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    [FormControlEventHandler(formControlStr(LedgerJournalTransDaily, FormButtonControl2), FormControlEventType::Clicked)]
    public static void FormButtonControl2_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        FormRun             formRun = sender.formRun() as FormRun;
        FormDataSource      ledgerJournalTrans_ds = sender.formRun().dataSource(formDataSourceStr(LedgerJournalTransDaily, LedgerJournalTrans));
        LedgerJournalTrans  ledgerJournalTrans_line;
        LedgerJournalTrans  tmp_trans;
    
        ledgerJournalTrans_line = ledgerJournalTrans_ds.getFirst(true) ;
    
        info(strFmt("running gs1 corrections %1" , ledgerJournalTrans_line.JournalNum));
    
        ttsbegin;
        while select forupdate tmp_trans where tmp_trans.JournalNum == ledgerJournalTrans_line.JournalNum  && tmp_trans.CorrectedGSTAmount!=0
        {
            //if(tmp_trans.CorrectedGSTAmount !=  ledgerJournalTrans_ds.correctedTaxAmount(false,tmp_trans,tmp_trans.CorrectedGSTAmount))
            {
                info(strFmt("complete %1 %2", tmp_trans.LineNum, tmp_trans.CorrectedGSTAmount)) ;                
                ledgerJournalTrans_ds.correctedTaxAmount(true, tmp_trans,  tmp_trans.CorrectedGSTAmount);
            }
        }
        ttscommit;
    }

}


Error:  ClassDoesNotContainMethod: Class 'FormDataSource' does not contain a definition for method 'correctedTaxAmount' and no extension method 'correctedTaxAmount' accepting a first argument of type 'FormDataSource' is found on any extension 


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>