Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Dynamics AX form datasource: bind to top 50 records

$
0
0

Hi,

 

I have one requirement where I need to limit the number of records (to max 50) fetched from form's datasource.

 

Below are the things I need to achieve:

 

If (mycondition == true)

{

                1. Dynamically add one inner join to form's datasource's query.

                2. Add an order by clause to query resulted from step 1.

                3. Select only top 50 records from result query in step 2.

}

else

{

                super(); //use form datasource's static query as it is.

}

 

I am trying to implement above logic in executequery() method of form datasource, but somehow not able to get it right.

 

Please suggest how can this be achieved. Below is the actual code snippet that I am trying in my if block above:

 

                while SELECT EmailMessage, EmailSubject, SalesOrder, ReceiverEmailAddress,

            SenderEmailAddress, SentDateTime, EventNotificationType

                    FROM retailEventNotificationLog

                    order by SentDateTime desc

                    join CustAccount from salesTable

                    where  retailEventNotificationLog. salesorder == salesTable.RecId &&

                        salesTable.CustAccount ==  custTable.AccountNum

 

        {

            if(counter > 50)

            {

                break;

            }

                    // Here I am trying to add current record to datasource but not getting it  right      

            counter++;

        }

 

        RetailEventNotificationLog_ds.refresh();


Viewing all articles
Browse latest Browse all 72043


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>