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

Community site session details

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

Query as a form datasource - Display method

(0) ShareShare
ReportReport
Posted on by

Hi All,

This could be silly but i somehow can't get it done.

I have an AOT query as a datasource of the form. It has 2 columns  amount1 and amount2.

Form has a Grid  and i want to show only 1 amount that is greater between amount1 and amount2 in a single column.

How do i do it?  Can we write a display method for an AOT Query ? Thanks in advance.

Regards,

Vikky

I have the same question (0)
  • Suggested answer
    VRD Profile Picture
    on at
    RE: Query as a form datasource - Display method

    Temporary table thing worked like charm. Just reading data from Aggregate entity and filling values in the table based on the condition.

  • VRD Profile Picture
    on at
    RE: Query as a form datasource - Display method

    As it's being used at multiple places, i don't want to touch the aggregate entity. Instead, I will use temporary table as a datasource in the form and i will fill the temp table by looping through the query results. while looping through this output, i can put my condition of whatever amount is greater, use it as the value of temporary table's field. I will bind this temp table to Grid.

  • WillWU Profile Picture
    22,361 on at
    RE: Query as a form datasource - Display method

    Hi Vikky,

    As Nikolaos metioned, please try adding a Computed column to data entity.

    docs.microsoft.com/.../data-entity-computed-columns-virtual-fields

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Query as a form datasource - Display method

    So, could you add the needed field in the Aggregate entity?

  • VRD Profile Picture
    on at
    RE: Query as a form datasource - Display method

    The problem is the aggregate entity. D365FO doesn't allow Aggregate entity to be part of View, not even if you add Query as a datasource  in the view.

  • VRD Profile Picture
    on at
    RE: Query as a form datasource - Display method

    Thanks Will.

    I was trying to add a datasource in the view and datasource always needs to be Table. But at View level, i can set its Query property. I will implement this and let you know how it goes.

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Query as a form datasource - Display method

    Will Wu nice, I was not aware of that you could use a query as a data source for a view. I assume there must be some limitations. But, quite cool.

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Query as a form datasource - Display method

    Hi,

    you are right, Query can't be used as a view data source. Queries are x++ objects, but views are SQL Server objects. And SQL Server can't use x++ objects as it's data source.

    But you can use a view as a query data source.

    Anyway, could you perhaps add this required field directly in the aggregate data entity?

  • WillWU Profile Picture
    22,361 on at
    RE: Query as a form datasource - Display method

    Hi Vikky,

    You could set the Query property of the view to create view based on query in D365FO.

    pastedimage1607674690338v1.png

  • VRD Profile Picture
    on at
    RE: Query as a form datasource - Display method

    Thanks Will and Niklaos.

    I have already explored that option of using View.  First of all, i can not add Query as a datasource into the View in D365FO.

    Secondly,  I have to use Query as it is being used at multiple places. Also, Query is using Aggregate Data Entity as its datasource.  D365FO doesn't allow to create a View using that Aggregate data entity as a datasource.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,333

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 681 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans