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

Modified field in Entity not working.

(0) ShareShare
ReportReport
Posted on by 113

Hi Experts,

I have created my custom Table and Entity. When I am entering the Percentage field value in form then Qty field automatically update. But when I am doing the same through entity the Qty field not updating. I have written the update code in Table - modifiedField method.
Can anyone help me on this.

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Harish, ModifiedField is a table method and won't be called automatically. However, I think you can call it inside Data Entity method like MapEntityToDataSource by providing table and field name.

    https://msdaxpulse.wordpress.com/2020/08/26/modifying-datasource-values-on-data-entities-using-mapentitytodatasource-method-on-data-entities-d365fo-x/

    www.dynamicsuser.net/.../52112

  • HARISH MEHRA Profile Picture
    113 on at

    Thanks Mohit.

    I will apply this .

  • GirishS Profile Picture
    27,827 Moderator on at

    Hi Harish,

    Modified field is an event and it will be triggered when field is modified. But you are talking about the data entity - Can you tell me how you are modifying the records using data entity?

    Thanks,

    Girish S.

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Girish,

    Actually I am calling table ModifiedField method from the Entity validateWrite().

    public boolean validateWrite()

       {

           boolean ret;

           StockPredictions_CAP stockPredictions_CAP;

           ret = super();

           stockPredictions_CAP.modifiedField(StockPredictions_CAP.Group1Percent);

           return ret;

       }

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    I will use insert or update table method for this scenario.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Instead of calling at validateWrite, can you try initValue or mapEntityToDataSource method of Data entity. And is it working in validateWrite?

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Mohit,

    InitValue method of data entity is not accepting  FieldId-->

    public void initValue(FieldId _fieldId)

    {

    super(_fieldId);

           switch(_fieldId)

           {

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    That's right, initValue will not accept fieldId. Please try below code.

    public void mapEntityToDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
    {
        DataEntityDatabaseOperation     dbOp = _entityCtx.getDatabaseOperation();
        stockPredictions_CAP stockPredictions;
     
        super(_entityCtx, _dataSourceCtx);
        
        if (dbOp == DataEntityDatabaseOperation::Insert || dbOp == DataEntityDatabaseOperation::Update)
        {
            switch (_dataSourceCtx.name())
            {
                case dataEntityDataSourceStr(YourCustomDataEntity, DataEntityDataSource):
                    CustomDataEntityName   customDataEntityRecord = _entityCtx.getEntityRecord();
    
                    stockPredictions = _dataSourceCtx.getBuffer();
                    stockPredictions.Group1Percent = customDataEntityRecord.Group1Percent;
     	            stockPredictions.modifiedField(fieldNum(stockPredictions_CAP, Group1Percent));
            }
        }
    }

  • HARISH MEHRA Profile Picture
    113 on at

    Hi Mohit,

    Yes this code works.

    Thanks!!

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

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 364 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans