Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Grid not refreshing based on new selected value on form

(0) ShareShare
ReportReport
Posted on by 125

First pic       3632.s1.PNG

second pic       0574.s2.PNG

last pic 5417.s3.PNG

Hi experts,my second lookup is getting value based on default enum mango when forms opens,but when i change this enum,it is not updating and showing old values. When i uncomment RetailStoreTable_ds.ExecuteQuery()  on selection change of first,an error comes up on form opening like registeroverridemethod was called twice for the same object for method 'text change'.Someone guide me how to update second filter based on first value?

*This post is locked for comments

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

    No Hossein Karimi, instead i used another approach for my scenario with single select.

  • Hossein.K Profile Picture
    Hossein.K 6,646 on at
    RE: Grid not refreshing based on new selected value on form

    Hi,

    Your problem is solved?Right?

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

    Hi ievgen Miroshnikov,

    One thing i forgot to mention,i did not use execute query method at all in above code i shared.

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

    Ok i start step by step

    1- 2451.enum1.PNG            2-       8015.proj.PNG

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

    As you can see I did not drag my parameters controls from forms data source(CFZSalesKPIReportTmp),instead used data source to fill my grid only.

    ///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();
    
    }
    


  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Grid not refreshing based on new selected value on form

    Error is coming from executequery and we were talking about modified, please share all code you have, because it's hard to say anything from your screenshot that show some bits and pieces only.

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

    Hi ievgen Miroshnikov,

    I tried this,form open up,i did change first lookup value,and when i am clicking on second lookup,this error comes,please tell me what does this error mean,why is this coming,because i tried other scenarios too and this error occurring frequently.

    0871.i.PNG

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Grid not refreshing based on new selected value on form

    Modified should be like:

    QueryRun qr;
    Query query = new Query();
    
    qbds1 = query.addDataSource
    ....
    
    qbds2 = qbds1.addDatasource
    .....
    
    qr = new QueryRun(query);
    
    if (msctrl1)
    {
    ...
    }
    else
    {
    ...
    }
    


  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

    Hi ievgan,

    I tried this and initialize it in init method of form  using  qr = new QueryRun(query) ,but same error comes up

    4213.t1.PNG            1362.t2.PNG

    When i use contructWithQuery on modifying,it takes range just first time when form opens,and on modifying first lookup it says Register override method was called twice for the same object for method 'text change'.

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Grid not refreshing based on new selected value on form

    Did you initialized qr? If not you need to do it first before using it in modified method. Or you can remove queryRun, create query only and use constructWithQuery method of multilookup.

  • Faran Baig Profile Picture
    Faran Baig 125 on at
    RE: Grid not refreshing based on new selected value on form

     I removed code from init and write code on modified

          4571.Capture1.PNG

    but on changing first lookup value,an error coming on line 5.

    820766.Capture.PNG

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans