web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to know which control calls the data source executeQuery method?

(0) ShareShare
ReportReport
Posted on by 332

Hello

There is a form named store transaction, this form by default opens with default date range.

Now I created a new button through the extension, this button will add a new range to dataSource

internal final class RetailTransactionTable_handler
{

    [FormControlEventHandler(formControlStr(RetailTransactionTable, ShowEReceipt), FormControlEventType::Clicked)]
    public static void ShowER_OnClicked(FormControl sender, FormControlEventArgs e)
    {
        QueryBuildRange qbrDate,status;

        FormDataSource fds = sender.formRun().dataSource(formDataSourceStr(RetailTransactionTable,TransactionTable));


        //fds.query().dataSourceNo(1).addRange(fieldNum(RetailTransactionTable,TransDate)).
        //   value(queryRange(fromDate,today()));

        fds.query().dataSourceNo(1).addRange(fieldNum(RetailTransactionTable,entryStatus)).
            value(strfmt("%1,%2",enum2str(RetailEntryStatus::Posted),enum2str(RetailEntryStatus::None)));

        fds.query().dataSourceNo(1).addRange(fieldNum(RetailTransactionTable,Type)).
            value(strfmt("%1",enum2str(RetailTransactionType::Sales)));

        fds.executeQuery();
            
    }

}
 

the standard execute query add range so if I added the range to the button, the standard range will replace my range

so I extended the executeQuery method, now I need to know which one calls the executeQuery method ( my button or standard functionality )

If standard functionality my range will be ignored, if the new button I will remove the standard range and put my range.

Sorry the post in the AX2012 community by wrong 

Thanks 

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Ahmed osama

    You are writing the code in the event handler or coc for execute query method. So both will be called.

    Can you tell which range you want the form to be filtered? I mean only you want filter based on custom range or you need both range to be added?

    Thanks,

    Girish S.

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    Dear Girish S

    Thanks, sorry I didn't get it.

    Is there any way to know which control calls the method ?

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    executeQuery will be called while opening the form and also during form refresh.

    For your scenario you have called the executeQuery method on button clicked method. So the executeQuery method will be called from your button only.

    Thanks,

    Girish S.

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    My code will be in executeQuery  (COC) so the code will run twice with the button and while opening the form also

    the new range will not be in the button because the executeQuery  will replace my range with its range every time

    Thanks

  • GirishS Profile Picture
    27,827 Moderator on at

    What you are trying to achieve?

    Can you elaborate?

    What type of button is "Show recipet"?

    Thanks,

    Girish S.

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    What you are trying to achieve?

    I just need to add a date range - but there standard range in the executeQuery, so the standard range replaces my range if I added the range code in the button.

    So if I added range in the executeQuery, I will replace the standard range, I don't need to do that.

    So I need to know which one calls the executeQuery method, the button, or while the form opens.

    Do you know how I can know the executeQuery caller?

    the type of showReceipt is button control .

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    If you think custom range is overriding the standard range, just add the standard range along with your custom range in the coc of executeQuery method.

    I mean just add the range implemented in the standard along with your custom range.

    Hope it's clear now...

    Thanks,

    Girish S.

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    thanks, but I can't do that because I just need one range implemented.

  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Normally if you write the code in COC or event handler - Code written by you and standard code will be concatenated. It will not be overridden.

    As per your scenario you are adding range to 3 fields. 

    1. TransDate
    2. EntryStatus
    3. Type.

    Now in the standard they have added below fields as a range.

    1. Store
    2. TransDate
    3. OfflineRange.

    All the 6 ranges will be applied as filter to the form except TransDate range. Because you can filter by either start date or end date or both start date and end date. 

    You cannot merge start date and end added by you and standard. So that's the reason why standard code is overridden and your custom code is added as date range.

    So your issue will be related only to date range other ranges will be applied without any issue.

    First you try to find out all the ranges applied to the form by adding query to the info log.

    Thanks,

    Girish S.

  • Ahmed Osama Ibrahim Profile Picture
    332 on at

    Thanks, Girish S.

    I solved it by creating a global variable

    I appreciated your effort

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans