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
  • SKO Profile Picture
    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
    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa Moderator

Leaderboard

Product updates

Dynamics 365 release plans