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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Fill column after lookup is modified

(0) ShareShare
ReportReport
Posted on by

Hi,

I have a grid with columns. When one of them (StringEdit with overriden lookup) is modified I want to fill another column's value. I've tried setting autodeclaration to yes and then set text property, but it doesn't work.

Any ideas how to do this?

Thank you in advance.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    The grid most probably displays table fields and not unassigned StringEdits. So the correct approach would be to override the modifiedField method of the table and put your logic there (when field x changes, fill field y).

    If it's indeed unassigned form controls it should work with autoDeclaration and the modified method.

  • Community Member Profile Picture
    on at

    It displays table fields.

    Any examples how to code in modifiedField method?

  • Suggested answer
    5400 Profile Picture
    7,162 on at

    It is very simple. If you need only in form level you can override the modify method in control and write code to assign the another column. If you need global for this table please use table modifyfield method.

    If both column is bound control please write code as below in lookup control

    public void modified()

    {

       super();

       //second column

        table.field = your value // Should be same data type. otherwise conversion is required && if it is bound control.

       // If it is un-bound string control made auto declaration yes and write below code

        strinfEdit.text('your value')

    }

    If you want to write table level please check modifyfield method is there or not if it is not there please ovveride

    write as below code

    public void modifiedField(FieldId _fieldId)

    {

    super(_fieldId);

    switch (_fieldId)

    {

    case fieldNum(TableName, FieldName) : // Look up control

    this.FieldName=' Your value'

    break;

    }

  • Verified answer
    Community Member Profile Picture
    on at

    Just check a standard modifiedFieldValue/modifiedField method to see how they work (There are two different methods that do the same. I don't know the difference). Almost all bigger tables have them.

    e.g. InventTable.modifiedFieldValue

    The method gets the modified field passed and then there is a switch case on the passed field. If it is your field that was passed, you can assign values to other table fields in the case.

  • Sohaib Cheema Profile Picture
    49,679 Super User 2026 Season 1 on at

    I do agree with jens

    writing code at table level is more better option in this case to prompt it from anywhere

    proceed for modifiedField with code as under

    case fieldNum(TableName,FieldName1):

               this.FieldName2 = 'SOME VALUE';

    break

  • Community Member Profile Picture
    on at

    Hi Bhaskar,

    As I said in first post, it doesn't work that way.

    Hi Jens,

    Thank you very much, now it works just fine.

  • Community Member Profile Picture
    on at

    Hi, I did assign values in other tables. I created modified field in inventtablemodule, if I change a value in a field, it will update a field in BOM table. However, the data is display in form not display the real data that already change in inventtablemodule. But when I debug, after finish debug, the field value can change. But if i am not doing debug, the value not show the real time data in the form of BOM as datasource.

    public void modifiedField(fieldId _fieldId)

    {

       super(_fieldId);

       if(this.isFormDataSource())

       {

           switch(_fieldId)

           {

               case fieldnum(InventTableModule,UnitId):

               this.PopulateInventUnit();

               this.updateBOMID();

               break;

           }

       }

    }---------------------

    void updateBOMID()

    {

       BOM                     tblBOM;

       InventItemInventSetup   inventItemInventSetup;

       inventDimId             inventDimBlank;

       InventTableModule       inventTableModule,inventTableModule2,inventTableModule3;

       InventTable             inventTBL;

       str id,id2,id3;

       ;

      if(this.UnitId!='STOP')

      {

           ttsbegin;

           select forupdate tblBOM

           where tblBOM.ItemId == this.ItemId ;

           {

           Select inventTableModule

           where inventTableModule.ModuleType == ModuleInventPurchSales::Invent && inventTableModule.ItemId == this.ItemId;

               {

               tblBOM.UnitId = inventTableModule.UnitId;

               tblBOM.doupdate();

               }

           }

           ttscommit;

        }

    }

    Can anyone help me.Thanks

  • Community Member Profile Picture
    on at

    You are probably missing a reread/refresh or research of the data source but note that you should not run any updates in a modifiedField method. ModifiedField is triggered as soon as a field is modified while the record is most likely not yet updated. If you update a related record and then the update of the main record fails or is aborted by the user, you will have inconsistent data. You should only update related records if the main record is updated as well.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans