Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Wednesday, February 11, 2015

Multiple query values on same field in X++(Dynamic query)

Hi,

static void AlfasithMultipleQueryValue(Args _args)
{
    HcmWorker                         HcmWorker;
    QueryRun                             queryrun;
    QueryBuildDataSource        qbdsHCWorker;
    QueryBuildRange                qbr1, qbr2;
    Query                                   query;
    ;

    query = new query();
    qbdsHCWorker = query.addDataSource(tableNum(HcmWorker));
    qbr1= qbdsHCWorker.addRange(fieldNum(HcmWorker,PersonnelNumber));
    qbr1.value("0012547");

    qbr2= qbdsHCWorker.addRange(fieldNum(HcmWorker,PersonnelNumber));
    qbr2.value("002211457");

    queryrun    = new queryrun(query);
    while(queryrun.next())
    {
        HcmWorker   = queryrun.get(tablenum(HcmWorker));
        info(strfmt('%1 – %2',HcmWorker.name(),HcmWorker.email()));
    }
}

Regards,


Saturday, January 24, 2015

To get the latest Purch price and sale price of an Item in AX 2012

Hi,

static void AlfasithInventDimInventTableRelation(Args _args)
{
    InventTable             InventTable;
    InventDim               InventDim;
    InventDimCombination    InventDimCombination;
    PriceDiscTable          PriceDiscTable;

    while select InventDimId from InventDim where InventDim.InventColorId == " "
                       &&   InventDim.InventStyleId == " "
                       &&   InventDim.configId == " "
                       &&   InventDim.InventSizeId == " "
        {
            select InventDimCombination where InventDimCombination.InventDimId == InventDim.inventDimId
                                        && InventDimCombination.ItemId == "1035";
            if(InventDimCombination)
            {
                select PriceDiscTable where PriceDiscTable.ItemCode == 0
                                &&  PriceDiscTable.ItemRelation == "1035" // Item Id
                                &&  PriceDiscTable.InventDimId  == InventDimCombination.InventDimId
                                &&  PriceDiscTable.FromDate     <= today()
                                &&  PriceDiscTable.ToDate       >= today()
                                &&  PriceDiscTable.relation     == PriceType::PricePurch // for Purch pirce
                                //&&  PriceDiscTable.relation     == PriceType::PriceSales // for Sales pirce
                ;
                print PriceDiscTable.Amount; // when
            }
        }
}

Regards,

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...