Create Loyalty Point Customer via X++


static void TIDF_TestCreateLoyaltyPointCustomer(Args _args)
{
    //table
    RetailLoyaltyCustTable      retailLoyaltyCustTable;
    RetailLoyaltyMSRCardTable   retailLoyaltyMSRCardTable;
    RetailLoyaltyMSRCardTrans   retailLoyaltyMSRCardTrans;
    AxRetailLoyaltyMSRCardTable AxRetailLoyaltyMSRCardTable;
    RetailLoyaltySchemesTable   RetailLoyaltySchemesTable;
    
    //field
    RetailLoyaltyCustId     retailLoyaltyCustId;
    CustAccount             custAccount;
    RetailLoyaltySchemeId   retailLoyaltySchemeId;
    RetailLoyaltyCardId     retailLoyaltyCardId;
    RetailLoyaltyPoints     retailLoyaltyPoints;
    
    retailLoyaltyCustId = "XXTESTXX03";
    custAccount         = "010203";
    retailLoyaltySchemeId = "2";
    retailLoyaltyCardId = "XXTESTXX10";
    retailLoyaltyPoints = 50;

    //save header
    retailLoyaltyCustTable.clear();
    retailLoyaltyCustTable.initValue();
    retailLoyaltyCustTable.accountNum = custAccount;
    retailLoyaltyCustTable.initFromCustTable(CustTable::find(custAccount));
    retailLoyaltyCustTable.loyaltyCustId = retailLoyaltyCustId ;
    retailLoyaltyCustTable.insert();

    //save lines
    AxRetailLoyaltyMSRCardTable =  new AxRetailLoyaltyMSRCardTable();
    AxRetailLoyaltyMSRCardTable.parmLoyaltyCustId(retailLoyaltyCustTable.loyaltyCustId);
    AxRetailLoyaltyMSRCardTable.parmLinkId(retailLoyaltyCustTable.loyaltyCustId);

    RetailLoyaltySchemesTable = RetailLoyaltySchemesTable::find(retailLoyaltySchemeId);
    if(RetailLoyaltySchemesTable)
    {
        AxRetailLoyaltyMSRCardTable.parmLoyaltySchemeId(RetailLoyaltySchemesTable.loyaltySchemeId);
    }

    AxRetailLoyaltyMSRCardTable.parmLoyaltyTender(RetailLoyaltyTenderTypeBase::AsCardTender);
    AxRetailLoyaltyMSRCardTable.parmCardNumber(retailLoyaltyCardId);
    AxRetailLoyaltyMSRCardTable.save();
    
    //upload points.
    retailLoyaltyMSRCardTrans.clear();
    retailLoyaltyMSRCardTrans.loyaltySchemeId = RetailLoyaltySchemesTable.loyaltySchemeId;
    retailLoyaltyMSRCardTrans.loyaltyCustId   = retailLoyaltyCustId;
    retailLoyaltyMSRCardTrans.cardNumber      = AxRetailLoyaltyMSRCardTable.retailLoyaltyMSRCardTable().cardNumber;
    retailLoyaltyMSRCardTrans.entryType       = RetailLoyaltyEntryTypeBase::Sale;
    retailLoyaltyMSRCardTrans.expirationDate  = maxDate();
    retailLoyaltyMSRCardTrans.points          = retailLoyaltyPoints;
    //include store or staff or any
    //retailLoyaltyMSRCardTrans.storeId   
    
    retailLoyaltyMSRCardTrans.insert();


}
Advertisements

lookup using view example x++

 
Capture
 

public void lookup()
{

     QueryBuildDataSource queryBuildDataSource;
    //super();
    //coded by fanddy, 
     SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(TIDInventLookup), this);

     Query query = new Query();

     queryBuildDataSource = query.addDataSource(tableNum(TIDInventLookup));
     sysTableLookup.addLookupfield(fieldnum(TIDInventLookup,NameAlias));
     sysTableLookup.addLookupfield(fieldnum(TIDInventLookup,DisplayProductNumber));
     sysTableLookup.addLookupfield(fieldnum(TIDInventLookup,Name));
     sysTableLookup.parmQuery(query);
     sysTableLookup.performFormLookup();

}

error : “”Object reference not set to an instance of an object” when open SSRS Report

try one or all of this solutions below :
1. Generate Incremental CIL
2. Compile on the customized report including report class (Contract, controller, DP). If you have modified TMP table , please do synchronize on that table.
3. Clean User Usage data on Tools-> Option -> Usages Data.
4. Restarting reporting services.
5. Refresh all cache on AOT, on AOT-> Tools -> Caches
5. Re-Deploy the SSRS report.
6. Restarting AOS. << sometimes it works like magic -_-“

Fixed Asset Projection Depreciation Expense example code

private void runWithAssetGroupId(NoYes parmendOfYearOnly,AssetGroupId assetGroupId)
{
    TmpDateSum      tmpDateSum;
    AssetTable      assetTable;
    AssetBook       assetBook;
    AssetBookTable  assetBookTable;
    //main account
    AssetLedgerAccounts  assetLedgerAccounts;
    MainAccountNum       mainAccountNum;


    while select assetTable
    join assetBook
    join assetBookTable
    where
        assetTable.AssetGroup                   == assetGroupId
    &&  assetTable.AssetId                      == assetBook.AssetId
    &&  assetBook.BookId                        == assetBookTable.BookId
    &&  assetBook.Depreciation                  == NoYes::Yes
    &&  assetBookTable.CurrentOperationsTax     == CurrentOperationsTax
    &&  assetBook.Status                        == AssetStatus::Open
    {

        lineTMP.clear();
        assetLedgerAccounts = AssetLedgerAccounts::find(assetBook.BookId,AssetParameters::find().PostingProfile,enum2int(AssetTransType::Depreciation),TableGroupAll::GroupId,assetTable.AssetGroup);
        mainAccountNum =  MainAccount::find(DimensionAttributeValueCombination::find(assetLedgerAccounts.OffsetLedgerDimension).MainAccount).MainAccountId;

        //Method calculation provided by AX
        tmpDateSum.setTmpData(assetBook.initDepreciationProfile());
        //set header line
        lineTMP.AssetGroupId = assetTable.AssetGroup;
        lineTMP.AssetId      = assetTable.AssetId;
        lineTMP.MainAccount  = mainAccountNum;
        lineTMP.rGrossFa     = assetBook.AcquisitionPrice;

        //cut off date
        while select tmpDateSum
        where
            tmpDateSum.TmpNumerals01 != 0
        &&  tmpDateSum.TransDate <= endYearDate
        {
            lineTMP.Period       = tmpDateSum.TransDate;
            lineTMP.rAccDepr     = tmpDateSum.TmpNumerals01;
            lineTMP.rDeprExp     = tmpDateSum.Total;
            lineTMP.rNetBookvalue = tmpDateSum.TmpNumerals02;
            lineTMP.insert();
        }

    }


}