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, ...
Answered

Force AOT Query range criteria of one field to bring records in accord with another range criteria

(1) ShareShare
ReportReport
Posted on by 65
Hello everyone,

I wanted to query ProdTable while setting the range value of ProdStatus on an aot query I created to the value released, when I click on filter to select records the prodId I get records that belong to all the status and not just to ProdStatus::Released
                    
[
    DataMemberAttribute,
    AifQueryTypeAttribute('_packedQuery', querystr(PordTableQuery)),
    SysOperationDisplayOrderAttribute('1')
]
public str parmQuery(str _packedQuery = packedQuery)
{
    packedQuery = _packedQuery;
    return packedQuery;
}
Is this even possible to lookup on the criteria column depending on Status?

Thanks in advance.
Categories:
I have the same question (0)
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    As far I know, it doesn't work that way. The range works on when the query is running. Not on the criteria column.
  • Suggested answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    This is a generic purpose´form for filtering any data in any table; it knows nothing about your particular scenario. You could extend the form, but it's not obvious how you'd identify that it's your specific case.
     
    Unfortunately, you didn't mention the business scenario, but the method you've shared shows that you're using a data contract class. Then a better solution may be using data members for the status and the order number and override the lookup of the latter.
  • Mohamed Fares BEN MILED Profile Picture
    65 on at
    Thank you Martin and Bharani for your insights.

    Martin I thought of the same thing but the user wants the dynamics query filtering and also lookup to ease his work by filtering ProdId with the status picked in the filter to fill up a temporary table with the ProdIds Raw materials.
    Is it possible to do both like in the screenshot below:

    The Production Id lookup bring the ProdIds with the range predefined in the AOT query, I tried to change the status (or do other filters) in the Records to include segment but it doesn't affect the production Id lookup, is it possible to make the Production Id lookup bring dynamically data using the same query filters set below in Records to include segment? 
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    Yes, you could use the query in the lookup.
  • Mohamed Fares BEN MILED Profile Picture
    65 on at
    Thank you Martin for the promt reply.
     
     I declared the lookup in the uibuilder class using the predefined Aot query.
    I tried to change the query in that form but it doesn't affect the lookup.
    Can you give me a code snippet on how to make that lookup filter dynamically according to the values of the query set in the "Records to include segment" ?
     
    Thank you again for your guidance.
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at
    It will help if you tell us more about what you already know and what you need from us. Just saying that you tried unknown code change and it didn't work isn't sufficient.
     
    If you tried to use the query in the lookup, it must mean that you already know (or believe so) how to get the query. But do you really have the right query? You see that you have no idea what's wrong if you don't test components of your solution, therefore let's change the approach.
     
    You need to check whether the query is correct, e.g. by looking at the variable in debugger. If it's correct, you know that this part of your code works and the problem is how you're using the query in the lookup. If it's wrong, there is no point in using this query in the lookup; you already know that it can't work. You'll need to review/debug your code for getting the query. You may also find that your code isn't called at all, therefore you need to fix that before you can even start testing.
  • Verified answer
    Mohamed Fares BEN MILED Profile Picture
    65 on at
    It was like you said Martin, that I am working with the same AOT query but with different instances.

    I used get query method from the contract class as my query in the uibuilder and it solved my problem.

    Thank you again for your help.

    PS: for some reason when I check "does this answer your question" for your answer it doesn't save it, maybe a mod can intervene and check your answer.

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans