Skip to main content
Dynamics 365 Community / Forums / Finance forum / refresh form after for...
Finance forum
Suggested answer

refresh form after formdatasource validate write

editSubscribe (1) ShareShare
ReportReport
Posted on by 1,375
 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
 
Attachments
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,218 User Group Leader 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
    Bharani Preetham Pe... 3,464 Super User 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
    Waed Ayyad 2,342 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
    Dineshkarlekar 1,375 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;
            }
     

Helpful resources

Quick Links

New Blog Features Released!

Check out the new community blog features for viewers and authors…

Demystifying Copilot with Sundar Raghavan

Sundar explains how Copilot for Service is meant to function separately...

Business Process Guidance Badges and New…

The Microsoft Success by Design is the framework for implementing Dynamics 365…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,281 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,017 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans