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)

Loop through all fields and compare records

(0) ShareShare
ReportReport
Posted on by

Hi,

Can anyone teach me how to loop in all fields? I have a table with a Emplid (not unique). The table store the history changes. what i want is when the field of the current record is empty. The empty field will be fill by the previous record. And those field of the current record that is not empty, will not be overwritten by the previous record.

Illustration:

Tprev: F1 F2 F3 F4 F5....

Tcurrent: _ f2 _  _   f5...

Tcurrent display =  F1 f2 F3 F4 f5

This Tprev and Tcurrent is the same Emplid and differ only in RecordSequence#. 

i already get their record position to determine which is the prev and the current record.

 

thanks,

 

 

*This post is locked for comments

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

    The following code illustrates how to get values from current record. The strange code "tCurrent.(fieldId)" is equivalent to tCurrent.SomeField, but using field ID.

    SysDictTable dictTable = new SysDictTable(tCurrent.TableId);
    SysDictField dictField;
    FieldId fieldId = dictTable.fieldNext(0);
    
    while (fieldId)
    {
        dictField = dictTable.fieldObject(fieldId);
        if (dictField.isSql() && !dictField.isSystem())
        {
            info(strFmt("%1: %2", dictField.name(), tCurrent.(fieldId)));
        }
        fieldId = dictTable.fieldNext(fieldId);
    }

    BTW are you aware of that your design doesn't support removing of field values?

  • Community Member Profile Picture
    on at

    Hi Mar,

    Yeah.I dont want to remove the value but instead copying the value of fields of the previous record to the null fields of current records.

    thanks,

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

    I mean: when user sets a value of a numeric field (for example, the same is true for all types) from 1 to 0, "1" will be still shown because the new value is considered "empty". AX doesn't support NULL values in database.

  • Community Member Profile Picture
    on at

    Error Occur while using tCurrent.(fieldId) at line number 10

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

    It would help if you at least told us what error you got. We can't read your mind.

  • Community Member Profile Picture
    on at

    I have also attach error photo but it seems its not uploaded by the way I resolve my issue.

    Thanks for your concern.

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