web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to refresh the data source in DataEventHandler?

(0) ShareShare
ReportReport
Posted on by 843

Hello,

Is it possible to refresh/reread datasource 'SalesLine' in 'SalesTable' form?

 [DataEventHandler(tableStr(SalesLine), DataEventType::Updating), SuppressBPWarning('BPParameterNotUsed', 'False positive')]
    public static void SalesLine_onUpdating(Common sender, DataEventArgs e)
    {
        SalesLine salesLine = sender as SalesLine;
        
        //some logic
    }

Thanks.

I have the same question (0)
  • GirishS Profile Picture
    27,825 Moderator on at
    RE: How to refresh the data source in DataEventHandler?

    Hi Shooowtek,

    You are asking how to refresh SalesLine in SalesTable form. But your code seems to be event handler for table. Can you elaborate more?

    From my knowledge it's not possible to get the DataSource buffer inside the table event handler.

    Thanks,

    Girish S.

  • Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: How to refresh the data source in DataEventHandler?

    Hi, Is this event handler from Form datasource or table level?

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    RE: How to refresh the data source in DataEventHandler?

    Try calling like salesLine.reread(); This will refresh that table with the present data.

  • Shooowtek Profile Picture
    843 on at
    RE: How to refresh the data source in DataEventHandler?

    On the SalesTable form, I update one field on the sales order lines. And it is required to refresh the SalesLine data on this form after this change.

    I know that this can be done easily through FormDataFieldEventHandler, but I can't use that because it has to be done directly on the table. Therefore, I use DataEventHandler.

    Thanks.

  • Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: How to refresh the data source in DataEventHandler?

    Can you please provide more details on why it has to be done directly on the table. I doubt if we can refresh form datasource from table level.

  • Shooowtek Profile Picture
    843 on at
    RE: How to refresh the data source in DataEventHandler?

    OK, I will try to solve differently to this problem and better try to the form.

    So, If by making a change to a field value on the SalesTable form and datasource SalesTable, can I able to refresh of the other source - SalesLine?

    [FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesTable, MyField), FormDataFieldEventType::Modified),
            SuppressBPWarning('BPParameterNotUsed', 'False positive')]
        public static void MyField_do_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
        {
            FormDataSource salesTable_ds = sender.datasource();
            FormDataSource salesLine_ds = sender.datasource("SalesLine"); //How to get SalesLine datasource??
            SalesTable salesTable = salesTable_ds.cursor();
    
            if(salesTable.orig().MyField != salesTable.MyField)
            {
                salesTable_ds.refresh();
                salesTable_ds.research(true);
                
                salesLine_ds.refresh();
                salesLine_ds.research(true);
            }
        }

  • Suggested answer
    Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: How to refresh the data source in DataEventHandler?

    There is a method doRefresh in SalesTable Form, you can try calling this method and pass parameter _lineRefreshNeeded as True.

    pastedimage1681455214624v1.png

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 588 Most Valuable Professional

#3
Sumit Singh Profile Picture

Sumit Singh 544

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans