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

How to add Order Totals to sales order form, but the fields must be able to filter on.

(0) ShareShare
ReportReport
Posted on by 235

I have the requirement to add the Order Total to the SalesTable form in the grid.  I was able to add the field using a display method. see code below:  However the client has a further requirement that they must be able to filter on this new field.  It is not possible to filter on a display message so I have proposed to create a new form with a view that contains the totals and then they can navigate to the SalesTable from there.

But now I am struggling to create a view with a column displaying the OrderTotal.  Is it possible to do this with a computed column.  Is there a different/better way to do this.  The problem is all the examples of computed columns refer only to values in the current view, what do you do if you want to sum() of column in a different table.

[SysClientCacheDataMethodAttribute(true)]

public static display AmountCur PBFOrderTotal(SalesTable _salestable)

{

AmountCur totalOrder,

invoiceAmount;

SalesTotals salesTotals;

CustInvoiceTrans custInvoiceTrans;

salesTotals = SalesTotals::construct(_salestable);

totalOrder = salesTotals.totalAmount();

select sum(LINEAMOUNTMST) from custInvoiceTrans

     where custInvoiceTrans.SalesId == _salestable.SalesId;

totalOrder = totalOrder + custInvoiceTrans.LINEAMOUNTMST;

return totalOrder;

}

I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Here is a simple example using SUM(): Subqueries in views.

    Nevertheless I don't understand your code. Using SalesTotals gives you the most precise numbers, but it's slow and you can't use it in computed columns. Summarizing LineAmountMst is efficient and can be used in computed columns, but it's not necessarily the same thing as a total amount of the order (for example, think about a discount applied to the total order, not lines). But I don't understand why you add these two numbers together.

  • Sophia.r Profile Picture
    235 on at

    Hi Martin  Thank you for your quick response.  Orignally the requirement was to show the same value as when you select the Order total on the sales order but they wanted to see it in the grid.  However this calculation does not include the invoiced value, so I added the invoiced values.  I will see if I can solve this with the example you ave provided.

  • Sophia.r Profile Picture
    235 on at

    Hi Martin  Are you referring to  CustInvoiceTrans.LineAmountMst above.  If I use the LineAmountMst from CustInvoiceTrans then I do not get totals of the open orders.  I need to show the Total of the order whether it as been invoiced or not.

  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    Sorry, I overlooked that you're querying invoice lines and not order lines.

    The rest of my reply still applies (e.g. that you can't use SalesTotals in computed columns and that replacing it with a custom query may be tricky).

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 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans