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 :
Microsoft Dynamics AX (Archived)

How to sum the amount in the table and pass it to a field for the total

(0) ShareShare
ReportReport
Posted on by 1,295

Hi, 

I just need your help, I would like to know if how to pass the total amount to the field from one of the field in gridtable in form? can you help me on this? thank you

Ivan

*This post is locked for comments

I have the same question (0)
  • Nishant2408 Profile Picture
    705 on at

    Hi Ivan,

    you can write a simple query from the datasource table and fetch the sum of the amount field.

    let's say you have a table Table1 and amount field is there. Query will be like :

    Select sum(amount) from Table1 where {your condition};

    Table1.amount will give you the sum which you can pass as argument._

  • SII1MNL Profile Picture
    1,295 on at

    Field #1 : smmOpportunityTable.TotalNetAmount()

    As-is : Sum of field #4

    To-be : Default data is sum of field #4, but user can edit it.

    the field #1 is in display method which you cannot simply edit it. I want to edit the total amount. I hope you get the situation. Thank you.

  • Community Member Profile Picture
    on at

    Try this it will help you!

    static void SumOfField(Args _args)

    {

    Table1 table1;

    ;

    select sum(Field1) from table1;   //Use "where" condition if required

    info(strfmt("%1",table1.Field1));

    }

    You can pass this value where ever you want to!

    *If you need to insert this value to gridtable of a form then you can write this code to init() method of that form and assign this value to desire field. So whenever the form is initialized you can see that value in your gridtable field.

  • Mea_ Profile Picture
    60,284 on at

    @Gautam Verma

    What is the purpose of  "where table1.RecId !=0"  ?

  • Rati Sharabidze Profile Picture
    612 on at

    Hi Ivan, you can create a display method in the datasource and put it in the grid. Remark: there will be no data field in the grid control. There will be Data method instead.

    Best regards

  • Community Member Profile Picture
    on at

    It will help to fetch all the row records of a table.

    Till it finds the records in table it will work.

  • Verified answer
    Nishant2408 Profile Picture
    705 on at

    Hi Ivan,

    I have got our question now. As you explained, in total amount field data is coming from a display method which is not editable. But in your case it has to be editable, which seems a bit confusing requirement because total amount is sum of field #4 in sumOpportuinityTable, if user is going to edit it , there is no point in showing some of a particular field. Anyways based on your requirement in place of display method you can use edit() method which will make the field editable as well. Perform the same logic in edit method which will return your total amount.

    For more information go through the link.

    msdn.microsoft.com/.../aa637541.aspx

  • SII1MNL Profile Picture
    1,295 on at

    Hi Nishant,

    Thank you for your response, yes its quite complicated what the client wants because it is not consistent at all. but I managed to set the field as editable since there is a field in the table for the computation. 

    Ivan

  • Suggested answer
    Code Work Profile Picture
    15 on at

    you can try this display method scenario is same

    community.dynamics.com/.../535285

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans