Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

Modified field in Entity not working.

(0) ShareShare
ReportReport
Posted on by 100

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.

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Modified field in Entity not working.

    Hi Mohit,

    Yes this code works.

    Thanks!!

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Modified field in Entity not working.

    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
    HARISH MEHRA 100 on at
    RE: Modified field in Entity not working.

    Hi Mohit,

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

    public void initValue(FieldId _fieldId)

    {

    super(_fieldId);

           switch(_fieldId)

           {

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Modified field in Entity not working.

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

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Modified field in Entity not working.

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

  • HARISH MEHRA Profile Picture
    HARISH MEHRA 100 on at
    RE: Modified field in Entity not working.

    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;

       }

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 on at
    RE: Modified field in Entity not working.

    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
    HARISH MEHRA 100 on at
    RE: Modified field in Entity not working.

    Thanks Mohit.

    I will apply this .

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Modified field in Entity not working.

    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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans