Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to refresh the data source in DataEventHandler?

(0) ShareShare
ReportReport
Posted on by 737

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.

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 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

  • Shooowtek Profile Picture
    Shooowtek 737 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);
            }
        }

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 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
    Shooowtek 737 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.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 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.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: How to refresh the data source in DataEventHandler?

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

  • GirishS Profile Picture
    GirishS 27,821 Super User 2024 Season 1 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.

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... 292,162 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans