Add Range to Data Source on Form method:Init example code

example code :


retailPeriodicDiscount_ds.query()
.dataSourceTable(tableNum(RetailPeriodicDiscount))
.addRange(fieldNum(RetailPeriodicDiscount, PeriodicDiscountType))
.value(queryValue(_discountType));

example form on AX 2012 : RetailPeriodicDiscount

Custom lookup example code x++ AX 2012

Example of custom lookup for itemid on PurchLine , form : PurchTable

public void lookup()
{
 SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);
 Query query = new Query();
 QueryBuildDataSource queryBuildDataSource, queryBuildDataSource2;
 QueryBuildRange queryBuildRange, queryBuildRange2;
 QueryBuildLink queryBuildLink;
 BuyBackScheme BuyBackScheme;
 str FilterCategory;
 //super();

 queryBuildDataSource = query.addDataSource(tablenum(InventTable));
 //add by Fanddy
 if(InventBuyerGroup::find(PurchTable.ItemBuyerGroupId).InventOwnership == InventOwnership::MD)
 {
 queryBuildDataSource = queryBuildDataSource.addDataSource(tableNum(PdsApprovedVendorList));
 queryBuildDataSource.joinMode(JoinMode::InnerJoin);
 queryBuildDataSource.relations(true);

 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,PdsApprovedVendor)).value(PurchTable.OrderAccount);
 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,ValidFrom)).value(strFmt(“<= %1″,DateTimeUtil::date(DateTimeUtil::removeTimeZoneOffset(PurchTable.createdDateTime,TimeZone::GMTPLUS0700_BANGKOK_HANOI_JAKARTA))));
 queryBuildDataSource.addRange(fieldNum(PdsApprovedVendorList,ValidTo)).value(strFmt(“>= %1″,DateTimeUtil::date(DateTimeUtil::removeTimeZoneOffset(PurchTable.createdDateTime,TimeZone::GMTPLUS0700_BANGKOK_HANOI_JAKARTA))));

 }
 //END by fandd

 sysTableLookup.addLookupfield(fieldnum(InventTable, itemId));
 sysTableLookup.addLookupMethod(‘itemName’);
 sysTableLookup.addLookupMethod(‘itemGroupId’);
 sysTableLookup.addLookupfield(fieldnum(InventTable, NameAlias));
 sysTableLookup.addLookupMethod(tableMethodStr(InventTable,pdsDefaultOrderType));
 sysTableLookup.addLookupfield(fieldnum(InventTable, RetailType));
 sysTableLookup.parmQuery(query);
 sysTableLookup.performFormLookup();

}

happy daxing !

 

Column BackColor Grid Form AX 2012

override method displayOptions in gridForm.

public void displayOption(Common _record, FormRowDisplayOption _options)
{
   #define.Red(255,0,0)
   TableNameDataSource   tableNameLoc;

   tableNameLoc = _record.data();

   //your logic if while etc
    
   _options.backColor(WinAPI:RGB2int(#Red);
   _options.affectedElementsByControl(element.controlId(CONTROL_NAME_IN_FORM));
   
   super(_record,_options);
   
}

contributor : _le

Multi Print Report based on Selected Items on Grid

void clicked()
{
    //AIFD_PrintBarcode
    AI_PrintBarcodeController aiBarcode = new AI_PrintBarcodeController();
    AI_PrintBarcodeContract aiContract = new AI_PrintBarcodeContract();
    ProdJournalProd prodJournalProdLoc;

    super();

    prodJournalProdLoc = ProdJournalProd_ds.getFirst(true);

    while (prodJournalProdLoc)
    {
        aiBarcode.parmReportName(ssrsReportStr(AI_PrintBarcoderReport,Report));
        aiBarcode.parmShowDialog(false);
        aiContract.parmRecordId(prodJournalProdLoc.RecId);
        aiContract.parmDocumentTitle(“x”);
        aiBarcode.parmReportContract().parmRdpContract(aiContract);
        aiBarcode.startOperation();

        prodJournalProdLoc = ProdJournalProd_ds.getNext();
    }
    //END
}