Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

How to get field value from FORM?

Posted on by Microsoft Employee

Hello!

I guess I have a fairly easy question, but I still require assistance...

I have to fill field with values, depending on current data in form, and for that I am writing display method, with select statement, that will fetch the data  I need, but how do I get those values in that FORMS fields.

For better understanding, lets say I have from FORM and fields A, B, C, D

I need to fill field D (display method) with values depending on values in field C.

Thanks you for assistance!

*This post is locked for comments

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: How to get field value from FORM?

    If you write a display method on a form, you have to pass the current record as a parameter. For example, you get _table1 buffer and refer to the field as _table1.FieldC.

    Note that you typically want display methods on tables, so you can use them in several forms and cache their values (which is important especially if you communicate with database inside the method).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get field value from FORM?

    Thank you!

    That did work!

    but still - if I write display method for datasource (not Table), how can I refer to fields current value?

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,188 Most Valuable Professional on at
    RE: How to get field value from FORM?

    Your example isn't clear to me, so let's assume that you have a table called Table1 with a field called FieldC.

    Then write a display method on the table and refer to FieldC as this.FieldC. Do your magic and return some value from the method (which represents D). Bind a form control to this method and you're done.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get field value from FORM?

    Yes, I know about that - but how can I get the FIELD C value? 

    So, If I add the method to properties and write

    Table table;

    DataSourcetable dsTable; 

    select FIELD from table

    where  table.FIELD1 == dsTable.D; (will this be the fields D value in form ?)

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,253 Super User 2024 Season 2 on at
    RE: How to get field value from FORM?

    Hi MrRobot,

    For normal fields the properties DataSource and DataField are used.

    To display a displaymethod you can use the properties DataSource and DataMethod. So the method name should be entered in the DataMethod property.

    Make sure the display method is or defined on the table itself or a new method on the 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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans