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

Display method value is updated on all records on grid

(3) ShareShare
ReportReport
Posted on by 312
Hello
I am using D365fo. I have a display method on a form data source through extension and used the method on a grid which has fields from two different data sources. My display shows data correctly, but the problem is when a row is highlighted, the value from currently highlighted row on display method field updates the value of all the rows on display method field on the grid. 
Here is my method
 
public display customfield Number(ReqTransCov  _reqTransCov)
{
    FormDataSource ReqTransSettledDS = this.formRun().dataSource("ReqTransSettled");
    ReqTrans reqTransSettled = ReqTransSettledDS.cursor();
    xxxProductAttributes     ProductAttibute;
    if (reqTransSettled.RefType == ReqRefType::ProdLine)
    {
        ItemId  itemId =  ProdTable::find(reqTransSettled.RefId).ItemId;
        select firstonly ProductAttibute
            where ProductAttibute.Product == InventTable::find(ProdTable::find(reqTransSettled.RefId).ItemId).Product;
    }
    else if (reqTransSettled.RefType == ReqRefType::Sales)
    {
        select firstonly ProductAttibute
           where ProductAttibute.Product == InventTable::find (_reqTransCov.ItemId).Product;
    }
    return ProductAttibute.Num;
}
 
Thanks
  • SKO Profile Picture
    312 on at
    Display method value is updated on all records on grid
    Thank you very much for enlightening me.
  • Verified answer
    Martin Dráb Profile Picture
    233,896 Most Valuable Professional on at
    Display method value is updated on all records on grid
    Your method will calculate for each ReqTransCov record, but it uses the same (the currently selected) ReqTrans in all cases. That's very likely not what you wanted, therefore your desing doesn't meet your own requirements.
     
    I'm assuming that ReqTransCov and ReqTransSettled data sources are joined and what you should do is getting ReqTrans from ReqTransCov (though either IssueReqTrans or ReceiptReqTrans relation), instread of taking the currently selected record from ReqTransSettled data source.
     
    By the way, if accessing the currently selected ReqTrans was the right thing to do, you could replace
    FormDataSource reqTransSettledDS = this.formRun().dataSource("ReqTransSettled");
    ReqTrans reqTransSettled = reqTransSettledDS.cursor();
    with mere
    reqTransSettled
    because there are a few automatically created variables for each data source, such as reqTransSettled with the selected record, reqTransSettled_ds representing the FormDataSource object and so on.
     
    And avoid hard-coding elements names as text. Instead, use functions like formDataSourceStr() to validate the name by the compiler and to include the reference in cross-references.
     

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 601 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 416

#3
Adis Profile Picture

Adis 384 Super User 2025 Season 1

Product updates

Dynamics 365 release plans