Tuesday 21 July 2015

how to pass multiple query value from an container or table to query run.

1.create a method in a class

str fieldListRange(FieldName _fieldName, str _value)
{

    container c;
    int countNumber;
    str rangeValue;
    A_InventImport   A_InventImport   ;
    ;

    while select * from  A_InventImport  
    {
     // c = conins(c,A_InventImport   .itemid);
     c+= A_InventImport   .ItemId;
    }

   for (countNumber = 1; countNumber <= conLen(c); countNumber++)

    {

    if(rangeValue)

    {

    rangeValue +="||";
    }

    rangeValue +="(" + _fieldName + " = \"" + strLRTrim(any2str(conPeek(c, countNumber))) + "\")";
    }
    return rangeValue;
}



then call this method in run method

queryRun.query().dataSourceTable(tablenum(inventsum)).addRange(fieldnum(inventsum,Closed)).value(queryvalue(noyes::Yes));
        queryRun.query().dataSourceTable(tablenum(inventsum)).addRange(fieldnum(inventsum,itemid)).value((strFmt("(%1) || (%2 = %3)",
        this.fieldListRange(fieldStr(A_InventImport   , ItemId), parameter1),
        fieldStr(A_InventImport   , ItemId), SysQuery::valueEmptyString())));

declare parameter1  as a string in the run method.

Wednesday 8 July 2015

add the item image to RDP report in ax 2012

   
//line below is the link  SalesQuotationTable  && custQuotationJour
 SalesQuotationTable                = custQuotationJour.salesQuotationTable();
        salesQuotationTmp.TCC_totalDiscount      = SalesQuotationTableloc.TCC_TotalDiscount;

        //if image is there
        if(SalesQuotationTable.PrintImage == NoYes::Yes)  //customized field
        {
        ProductImage = Inventtable::find(salesQuotationTmp.ItemId).RecId;
        ProductImage1 = docuRef::find(custQuotationTrans.dataAreaId,ProductImage).RecId;
        select ecoResProductImage
        where (ecoResProductImage.RefRecId              == ProductImage
                                  || ecoResProductImage.RefRecord                == ProductImage)
                                  && ecoResProductImage.DefaultImage == NoYes::Yes ;
        salesQuotationTmp.ItemImageLogo  = ecoResProductImage.MediumSize;

        }


above code can be used to get  image stored in ecoResProductImage for the item to your temp table in the SSRS report.

Tuesday 7 July 2015

Best 25 blogs in ax 2012

Please find the best 25 blogs in AX 2012 and they have been awarded a badge for the same.

http://www.dynamics101.com/2014/06/top-25-dynamics-ax-sites/

Friday 3 July 2015

Cannot edit a record in Sales orders (SalesTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

Some time when we do deletion  or updation.

then we might get error like
"Cannot edit a record in Sales orders (SalesTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record."

the solution for that is we need to add the

SalesTable.reread();

before  doing the SalesTable.update();

by doing this that error will not come  again.

                salesTable.reread();
                salesTable.CloseSO              = noYes::Yes;
                salesTable.update();




Thursday 2 July 2015

cancel sales order code with updating the inventory qty for the item in ax 2012

public static void closeSalesOrders(Guid _transId)
{
    #AviFiles
    SysOperationProgress        progress  = new SysOperationProgress();
   
    SalesTable                      salesTable;
    SalesLine                       salesLine;
    ;

    progress.setCaption("Sales order closing ....");
    progress.setAnimation(#AviSearch);
    try
    {
        ttsbegin;
     
            while select firstonly forupdate salesTable
                where salesTable.SalesId            == salesOrderClosing.SalesId
            {
                while select forupdate salesline
                    where salesLine.SalesId         == salesTable.SalesId
                    && salesLine.SalesStatus        == salesStatus::Backorder
                {
                    salesLine.RemainInventPhysical  = 0;
                    salesLine.RemainSalesPhysical   = 0;
                    salesLine.Complete              = noYes::Yes;
                    salesLine.Blocked               = noYes::Yes;
                    salesLine.update();
                    progress.setText('Processing item ' + salesLine.ItemId + ' with sales id ' + salesLine.SalesId + '.');
                }
             
                    }
               

        ttscommit;

    }
    catch(Exception::Error)
    {
        ttsabort;
    }
}

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...