record etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
record etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

26 Ocak 2021 Salı

AX 2012 - Send filter with args

 

If your filter just one record, you can run filter with args.record(). In the other case if you have to filter more than one record, you can't use record method. You can use InitialQueryParameter for this:

            Args                 args = new Args();
            MenuFunction         MenuFunction = new MenuFunction('LedgerJournalTable', MenuItemType::Display);
            Query                q = new Query();
            QueryBuildDataSource QBDS = q.addDataSource(tableNum(LedgerJournalTable));

            if (ABCRCreditTable.AccualJournalNum != "")
                QBDS.addRange(fieldNum(LedgerJournalTable,JournalNum)).value(ABCRCreditTable.AccualJournalNum);
            if (ABCRCreditTable.AccualJournalNum2 != "")
                QBDS.addRange(fieldNum(LedgerJournalTable,JournalNum)).value(ABCRCreditTable.AccualJournalNum2);

            args.initialQuery(InitialQueryParameter::createByQuery(q));
            args.caller(this);

            MenuFunction.run(args);  



22 Ocak 2016 Cuma

Axapta - Why sometimes MultiSelectionHelper and why sometimes traditional read?

That's the  traditional way to read selected records from a grid:

 c = CustTable_DS.getFirst(true);
 while (c.RecId != 0)
 {
      info(c.Name);
      c = CustTable_DS.getNext();
 }


But there's a problem with this way. If user just wants to process records at line instead of select a couple of records unfortunately that record will be missed. That's the workaround for this symptom:


c = CustTable_DS.getFirst(true);
noSelected = true;
while (c.RecId != 0)
{
     noSelected = false;
     info(c.Name);
     c = CustTable_DS.getNext();

}
if  (noSelected)
    info(CustTable.Name);

MultiSelectionHelper solves this problem:

 MultiSelectionHelper helper = MultiSelectionHelper::construct();
CustTable c;
;

helper.parmDatasource(CustTable_ds);

c = helper.getFirst();
while (c.RecId != 0)
{
      info(c.Name);
      c = helper.getNext();

}


But there is a disadvantage for MultiSelectionHelper class too. If user wants to sort records at grid and wants to process with this sorted list we have to use traditional way again  because unfortunately MultiSelectionHelper doesn't care about users sort.

Using MultiselectionHelper from a class:

public static void main(Args _args)
{
    SMAServiceOrderTable    serviceOrder;
    MultiSelectionHelper    helper;
    FormRun                 caller = _args.caller();
    FormDataSource          SMAServiceOrderTable_DS;
  
    SMAServiceOrderTable_DS = caller.dataSource();
    helper = MultiSelectionHelper::createFromCaller(caller);
    helper.createQueryRanges(SMAServiceOrderTable_DS.queryBuildDataSource(),fieldStr(SMAServiceOrderTable,RecId));
    
    serviceOrder = helper.getFirst();
    
    while(serviceOrder)
    {
        info(strFmt("%1",serviceOrder.RecId));
        serviceOrder = helper.getNext();
    }
}

11 Temmuz 2014 Cuma

AX 2012 - Send marked records to SSRS RDP Report

SSRS DP Class don't accept table or container data types as parm method. I searched at forums and saw str data type adviced. But I think this's not best approach. At last learned best way already in standard AX SSRS reports. At this link there's a PDF file tells look for check report. I generated this report with look form ChequeDP and ChequeController classes:

Controller class:

class declaration:

class myController extends SrsReportRunController
{
    #define.ReportName('myreport.Report')
   myTMPTable   myTMPTable;
}

public static void main(Args _args)
{
    SysLastValue    SysLastValue;
    myController controller = new myController();
    controller.parmReportName(#ReportName);
    controller.parmArgs(_args);
    controller.DeleteTmpData();
    controller.init();
    controller.startOperation();
}


protected void prePromptModifyContract()
{

    SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;

    new SRSReportRunPermission().assert();
    contract.parmTmpTableDataRecId(SRSTmpTblMarshaller::SendTmpTblToDataProvider(myTMPTable));

}


public void init()
{
    FormDataSource      ds;
    TransDate           transDate;
    VendTrans           vendTrans;


    if (!this.parmArgs()             ||
        !this.parmArgs().record()    ||
        this.parmArgs().dataset() != tableNum(VendTrans))
        throw error("Report should be call with correct parameter!..");

    ds = this.parmArgs().record().dataSource();

    vendTrans = ds.getFirst(1);
    transDate = vendTrans.transDate;
    PaymentReceipt.VendAccount = vendTrans.AccountNum;

    for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
    {
        myTMPTable.Date             = vendTrans.TransDate;

...
        myTMPTable.insert();
    }
}


DP Class:

// <ETG - memre > GN:   T: 11.07.2014 A:
[SRSReportParameterAttribute(classStr(SrsTmpTblMarshallerContract))]
public class mpDP extends SRSReportDataProviderBase
{
    myTMPTAble myTMPTable;
}


private void initTmpTable()
{
    SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;

    new SRSReportRunPermission().assert();

    myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());

    SRSTmpTblMarshaller::deleteTmpTblData(contract.parmTmpTableDataRecId());
    CodeAccessPermission::revertAssert();
}


public void processReport()
{

    CompanyInfo                 Company;
    VendTable                   vendTable;
    AmountMST                   amount;
    TempStr                     NumtoTxt;
    LedgerJournalTrans          LedgerTrans;

    this.initTmpTable();

...
}

14 Kasım 2013 Perşembe

AXAPTA - fast search with grid

Do not use find method for this, it works so slow with big tables. This's the way which Axapta uses with it's own forms:
 element.args().lookupField(fieldnum(SMAServiceOrderTable, ServiceOrderId));
element.args().lookupValue(_myServiceOrderId);
SMAServiceOrderTable_ds.executeQuery();

2 Aralık 2011 Cuma

AXAPTA Create new record at another form and return from

Sometimes you can want to or have to create new record  at another form. There are some Axapta forms do it with complex ways. I couldn't understand Axapta's ways.
This is mine simple way:

Main forms data source create method:


public void create(boolean _append = false)
{
    Args                args;
    FormRun             formCreate;
    ;

        args = new Args();
        args.name(formstr(B_ExpressServiceNew));
        args.caller(element);
        formCreate = classfactory.formRunClass(args);
        formCreate.init();
        formCreate.run();
        formCreate.wait();
}

B_ExpressServiceNew, is my new record forms name.
This part should write at new record forms new record method:


    if (element.args() && element.args().caller() && element.args().caller().name() == formstr(B_ExpressService))

    {
     mainForm = element.args().caller();
     mainForm.SetRecord(oTable);
    }


B_ExpressService is my main form, oTable is my new record.
Setrecord method at main form for locate new record:

void SetRecord(SMAServiceOrderTable _order)
{
    ;
    SMAServiceOrderTable.reread();
    SMAServiceOrderTable.data(_order);
    SMAServiceOrderTable_DS.setCurrent();

}