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

Display method value is updated on all records on grid

(3) ShareShare
ReportReport
Posted on by
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
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    Most Valuable Professional on at
    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.
     
  • SKO Profile Picture
    on at
    Thank you very much for enlightening me.

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

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

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

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans