Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

QueryRun Cursor Error

Posted on by 125

Hi experts,on modified method of Category lookup,written below code to get second lookup multi select.

5633.s1.PNG

0410.i2.PNG

on clicking store number lookup either first time when form opens up or after changing category lookup value,this error comes,i dont know why is this coming and what does it mean?Some guide me.

3542.i.PNG

*This post is locked for comments

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: QueryRun Cursor Error

    Hi Faran,

    Probably the next blog will help you with the multi-select lookup: community.dynamics.com/.../using-multi-select-lookup-control-in-microsoft-dynamics-ax-2012

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: QueryRun Cursor Error

    Hi André Arnaud de Calavon,

    Issue is that on lookup method of store number,code works for single select only.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: QueryRun Cursor Error

    Hi Faran,

    My initial thought is that the coding for the multi select should not be used on the modify of the category control. This is typically coding that belongs on a lookup method of the store number.

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: QueryRun Cursor Error

    Hi André Arnaud de Calavon,

    I tell u step by step.I am working on a custom form,like below,i want store number lookup multi select like in screen shot attached below and values in store number lookup drop down should come based on first lookup enum value(Concept lookup) at run time.

    Here i share details with you,i have added two controls for parameter,not from form datasource but by setting enum value and edt.

     Screen Shot   6862.enum.PNG

    1- i4.PNG            2-       8015.proj.PNG

     3-6862.enum.PNG   4-  2451.enum1.PNG   5- 7762.rt.PNG

    ///Class Declaration
    final class FormRun
    extends     ObjectRun
    {
       
        SysLookupMultiSelectCtrl msctrl1;
       
        boolean                     viewInventTrans;
        str fromdate;
        int64                  recordscount;
        RealBase                locinvoiceCount;
        ListEnumerator          listEnumStore;
        List                    listStores;
      
      
        RetailTransactionSalesTrans salestrans;
    
        InventDimCtrl_Frm_mov       inventDimFormSetup;
        InventTransReference        inventTransReference;
    
        int                         transactionView;
        NoYes                       linkView;
    
    
      
    
        #define.CurrentVersion(1)
        #localmacro.CurrentList
        transactionView
        #endmacro
    }
    
    
    //Form's Close
    public void close()
    {
         super();
    }
    
    
    /// Form's init
    void init()
    {
    
        super();
        
        viewInventTrans = false;
        tabSalesLine.visible(true);
    }
    
    
    ///cfzMask:modified  (category Lookup modified)
    public boolean modified()
    {
    
        boolean ret;
    
    
        QueryBuildDataSource        qbds1,qbds2;
        QueryBuildRange             qrStore;
        QueryRun                    qr;
    
        Query query = new Query();
        qbds1 = query.addDataSource(tableNum(RetailStoreTable));
        qbds2=qbds1.addDataSource(tableNum(RetailTerminalTable));
        qbds2.clearRange(fieldNum(RetailTerminalTable,CFZMask));
    
        qbds2.addRange(fieldNum(RetailTerminalTable,CFZMask)).value(SysQuery::value(cfzMask.valueStr()));
        qbds2.joinMode(JoinMode::InnerJoin);
        qbds2.addLink(fieldNum(RetailTerminalTable,StoreRecId),fieldNum(RetailStoreTable,RecId));
        qr = new QueryRun(query);
    
        if(msctrl1)
        {
            msctrl1.refreshQueryRun(qr);
        }
        else
        {
            msctrl1 = SysLookupMultiSelectCtrl::constructWithQueryRun(element,StoreID,qr);
        }
    
        ret = super();
        return ret;
    }
    
    ///DateTo:modified
    public boolean modified()
    {
        boolean ret;
    
        ret = super();
    
        return ret;
    }
    
    
    ///Search button:click
    void clicked()
    {
        CFZSalesKPIReportTmp    cfzSalesKPIReportTmploc;
      
      
        RetailChannelTable      retailChannelTable;
        RetailTransactionTable  retailTransactionTable,rtstemp;
        OMOperatingUnit                                         OmOperatingUnit;
      
        
     
    
        ;
    
        super();
    
        if(str2Date(BackorderDate.valueStr(),213) > str2Date(DateTo.valueStr(),213))
        {
            throw error("From Date cannot be greater than To Date");
        }
    
    
    
        delete_from CFZSalesKPIReportTmp;
    
        //if(listStores && !listStores.empty())
        //{
           //listEnumStore =  listStores.getEnumerator();
            //while(listEnumStore.moveNext())
            //{
               //storeid = listEnumStore.current();
    
    
    
    
           while select count(Recid),sum(grossAmount),sum(numberOfItems),sum(DiscAmount),channel,store
                from retailTransactionTable group by retailTransactionTable.store,retailTransactionTable.transDate,retailTransactionTable.Channel
                where retailTransactionTable.store == StoreID.valueStr()
                &&    retailTransactionTable.type  == RetailTransactionType::Sales
                &&    retailTransactionTable.entryStatus != RetailEntryStatus::Voided
                &&    retailTransactionTable.transDate >= str2Date(BackorderDate.valueStr(),213)
                &&    retailTransactionTable.transDate <= str2Date(DateTo.valueStr(),213)
    
          {
    
            recordscount = retailTransactionTable.Recid;
    
    
    
            Select firstonly1 retailChannelTable where retailChannelTable.RecId == retailTransactionTable.channel;
            cfzSalesKPIReportTmploc.clear();
            cfzSalesKPIReportTmploc.store = retailTransactionTable.store;
            cfzSalesKPIReportTmploc.Storename = DirPartyTable::findRec(retailChannelTable.OMOperatingUnitID).Name;
            cfzSalesKPIReportTmploc.transDate = retailTransactionTable.transDate;
            cfzSalesKPIReportTmploc.InvoiceCount = any2real(recordscount);
            locinvoiceCount = any2real(retailTransactionTable.RecId);
            if(retailTransactionTable.numberOfItems == 0)
            {
                cfzSalesKPIReportTmploc.UPT = 0;
            }
            else
            {
                cfzSalesKPIReportTmploc.UPT = (retailTransactionTable.RecId/retailTransactionTable.numberOfItems);
            }
    
            if(retailTransactionTable.grossAmount == 0)
            {
                cfzSalesKPIReportTmploc.ATV = 0;
            }
            else
            {
                cfzSalesKPIReportTmploc.ATV = (retailTransactionTable.RecId/retailTransactionTable.grossAmount);
            }
    
            if(retailTransactionTable.grossAmount == 0)
            {
                cfzSalesKPIReportTmploc.PerSquareFeetSales = 0;
            }
            else
            {
                cfzSalesKPIReportTmploc.PerSquareFeetSales =(retailChannelTable.StoreArea/retailTransactionTable.grossAmount);
            }
    
            retailTotalDiscAmount   = retailTransactionTable.grossAmount;
            if(retailTotalDiscAmount<0)
            {
               retailTotalDiscAmount = retailTotalDiscAmount>0 ? -retailTotalDiscAmount:abs(retailTotalDiscAmount);
               cfzSalesKPIReportTmploc.GrossAmount  = retailTotalDiscAmount;
            }
            else
            {
                cfzSalesKPIReportTmploc.GrossAmount  = retailTotalDiscAmount;
            }
    
            cfzSalesKPIReportTmploc.TotalQty =  retailTransactionTable.numberOfItems;
            cfzSalesKPIReportTmploc.StoreArea = retailChannelTable.StoreArea;
            retailDiscAmount =   retailTransactionTable.discAmount;
            
                cfzSalesKPIReportTmploc.totalDiscAmount = retailDiscAmount;
           
            cfzSalesKPIReportTmploc.insert();
    
    
    
         }
      
     
       CFZSalesKPIReportTmp_ds.research();
    
    }


  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: QueryRun Cursor Error

    Hi Faran,

    Can you explain what the variable 'msctrl1' is? Is the error caused by the 'if true' or 'if false' part of the lookup method? What do you mean with 'second lookup multi select'?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans