Skip to main content

Notifications

Community site session details

Community site session details

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

refresh form after formdatasource validate write

(1) ShareShare
ReportReport
Posted on by 1,609
 i have written the validate write method on form datasource the method is working fine but i need to refresh the form manually because when the error gets triggered the lines get dissaperar and after refresh the lines appear i cannot hit the refresh button all the time need to refresh form after validation . please suggest me how can i get it done .
below is my code
 
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    24,100 Super User 2025 Season 1 on at
    refresh form after formdatasource validate write
    Hi,
     
    try this :
    public boolean validateWrite()
    {
        boolean ret;
    
        ret = super();
    
        // your validation 
        if()
        {
            ret = ...
        }
    
        if(!ret)
        {
            {{YourTable}}_ds.reread();
            {{YourTable}}_ds.refresh();
            {{YourTable}}_ds.research().
        }
    
        return ret;
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    refresh form after formdatasource validate write
    You can achieve this by calling the research(true) for the header/first/main datasource.
     
    But I couldn't understand your code. The buffer which you are selecting, I don't find it anywhere in the code where you defined it. Also you are getting the invoice lines from cursor(). Then it is not required to use the select statement again to find the lines.
     
    Also I would suggest to understand why lines are getting disappeared instead of making it refresh from code.
  • Suggested answer
    Waed Ayyad Profile Picture
    8,590 Super User 2025 Season 1 on at
    refresh form after formdatasource validate write
    Hi,
     
    You can try to add the following code:
     
    YourDatasourceName_ds.reread();
    YourDatasourceName_ds.rereadreferenceeDatasource();
    YourDatasourceName_ds.research(true).
    
     
    Thanks,
    Waed Ayyad
    If this helped, please mark it as "Verified" for others facing the same issue
     
  • Dineshkarlekar Profile Picture
    1,609 on at
    refresh form after formdatasource validate write
         public boolean validateWrite()
            {
                boolean ret;
                DTDMCHeaderLines    dTDMCHeaderLinesInv = this.cursor();
                
                select firstonly DTDMCHeaderLines
                    where DTDMCHeaderLines.InvoiceId == dTDMCHeaderLinesInv.InvoiceId;
                if(DTDMCHeaderLines.RecId != 0)
                {
                    throw error('InvoiceId Already Exist');
                }
                ret = super();
    
                return ret;
            }
     

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