Friday, 10 November 2017

How to get customer credit card number based on Expiry date using x++ code


Get customer credit card number based on Expiry date validation 

public static RefRecId getCreditCardOCP(CustAccount    _custAccount)
{
    CreditCardCust custCreditCard;

    select firstOnly RecId,ExpiryDate from custCreditCard
            where custCreditCard.CustAccount == _custAccount;

    if(custCreditCard.ExpiryDate && CreditCard::checkExpireDate(custCreditCard.ExpiryDate))
    {
        return custCreditCard.RecId;
    }

    return 0;

}

Tuesday, 7 November 2017

How to get selected query range value using x++ code in Ax 2012 R3

To get selected query range value

In My case need to get selected query range value from existing query.

Conditions

  1. If  range is applied need to filter based on the range 
  2. If  range not applied default it should take system language


    QueryBuildDataSource    qbdsProductTranslation;
    QueryBuildRange         queryBuildRange;
    QueryFilter             queryFilter;
    QueryRun                queryRun;

    qbdsProductTranslation    = _query.dataSourceTable(tableNum(EcoResProductTranslation));
    queryFilter = _query.findQueryFilter(qbdsProductTranslation, fieldStr(EcoResProductTranslation,      LanguageId));

    if(!queryFilter || !queryFilter.value()) //To handle the situation like If languageId is added to Range set to empty and If LanguageId is not added to Range
    {
        queryBuildRange  = qbdsProductTranslation.addRange(fieldNum(EcoResProductTranslation,LanguageId));
        queryBuildRange.value(SystemParameters::getSystemLanguageId());
        queryRun = new QueryRun(_query);
        _query   = queryRun.query();

    }

//setExecutionIdRangesOCP