Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Unretrieved field in grid using query with group by

(0) ShareShare
ReportReport
Posted on by 5

Hello Everyone,

I'm really new to AX so i need your help.

I have a custom Form from custom Table which shows orker activity

pastedimage1587605801364v3.png

and i want to make another Form with Query Group By to show only one worker per row. it should be like this

pastedimage1587606268623v4.png

but instead, i get unretrieved Field like this 

pastedimage1587606368590v5.png

this is my query

pastedimage1587606489951v6.png

any help/guide/correction would be appreciated.

Regards,

Fahmi

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,503 Most Valuable Professional on at
    RE: Unretrieved field in grid using query with group by

    Your filters for ermpty strings have nothing to do either with NULL nor your problem with grouping.

    If you group by Worker and WOId and you don't use any aggregations, only those two fields will be obtained from database. All other fields won't have any value at all. If you want to get other fields, you must either group by them or decide how multiple values in a group should be aggregated to a single value (e.g. to get the minimum start date from records in the group).

    Why you don't get anything for Worker is a bit less intuitive. You group by Worker field, but it's not what's displayed in the form. Worker field contains record ID (a number), but it's not very useful, therefore you normally see worker names. But your don't group by worker name, therefore its value is undefined as well.

  • themet Profile Picture
    themet 5 on at
    RE: Unretrieved field in grid using query with group by

    Hi Ziyao,

    Thanks for the reply. After i searched about group by, AX does not able to works with null data so i added the range for supervisor, worker, WOID, starddate, and enddate with value = !""

    pastedimage1588214721829v2.png

    the table i want to query is looked like this 

    pastedimage1588214870971v3.png

    i made the Form to summarize the working time of each Worker from each WOID, and i placed the Query Form in Summarize button

    pastedimage1588215158708v5.png

    and it ended up like this

    pastedimage1588215215688v6.png

    how to fix this?

    Regards

    Fahmi.

  • Suggested answer
    Ziyao Profile Picture
    Ziyao on at
    RE: Unretrieved field in grid using query with group by

    The group by has two fields, workerOrderId and Worker. It can not be group by at the same time. Try to remove WOId and leave worker only, and then try it again.

  • themet Profile Picture
    themet 5 on at
    RE: Unretrieved field in grid using query with group by

    this is the Form and Query right now.

    pastedimage1587617954264v3.png

    i get the WorkOrderID but not the supervisor and Worker, and what is _CANNOT_D-> ?

    pastedimage1587618008734v4.png

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Unretrieved field in grid using query with group by

    You dont need having at all. Right click on fields node -> New -> Min (or Max) and add all the fields you need this way.

  • themet Profile Picture
    themet 5 on at
    RE: Unretrieved field in grid using query with group by

    pastedimage1587614802391v1.png

    this is my query now. am i doing it wrong?

  • themet Profile Picture
    themet 5 on at
    RE: Unretrieved field in grid using query with group by

    in SQL it should be like this :

    SELECT WorkOrderID, Supervisor, Worker, EndDate, StartDate

    FROM RS_WO_ActivityTrans

    GROUP Worker;

    it works just fine in SQL, but i dont know how to implement it on AOT Query.

    is it mandatory to apply MAXOF() or MINOF() function to every Datetime field? because i dont need that field on my Form.

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: Unretrieved field in grid using query with group by

    so you cannot just add fields you want, you should use aggregation functions. For example, 2 records for 1 worker may have different end date. So you need to decide what to do with it because you want to see only 1 row. You can use MAXOF() or MINOF() functions to select max or min date. You need to apply those functions to each field that is not a part of group by.

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!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans