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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Refresh datas from form

(0) ShareShare
ReportReport
Posted on by 229

Hi all,

I got 3 forms one opening another one and i need to find a way to when closing my third form to refresh data displaying on the first one.

pastedimage1670497895378v1.png

I hope my image will be correctly understood.

Regards.

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at

    Hi Mack Note,

    While calling the FormC from FormB pass the caller form as FormA and add the code to refresh caller DataSource (Here FormA will be caller DataSource) in FormC.

    Refer to the below code for refresh caller form datasource.

    https://axnotesblog.wordpress.com/2019/03/14/refresh-caller-form-in-d365fo/

    https://community.dynamics.com/365/financeandoperations/b/elandaxdynamicsaxupgradesanddevelopment/posts/how-to-refresh-a-calling-form-in-dyn365fo-with-a-simple-code-1533363044

    Thanks,

    Girish S.

  • Awaxx Profile Picture
    229 on at

    Hi Girish and all,

    I didn't understood how to do it

    I tried your ways but my formrun datasource got 'null' value.

    Could you explain step by step please ?

    Regards.

  • GirishS Profile Picture
    27,827 Moderator on at

    Can you share your code?

    Thanks,

    Girish S.

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Hi Mack,

    Create an event handler on clicked event of 3rd form Close button.

    Call the below method on main datasource of FormA.

    DS.executeQuery();

    DS.research();

    These methods help you in refreshing a form which does the same function where we will click refresh button on form.

  • Awaxx Profile Picture
    229 on at

    public void close()
    {
    super();
    Args args = new Args(formstr(FormA));

    FormRun formRun = classFactory.formRunClass(args);

    // If the caller is a form, refresh this form
    if(formRun)
    {
    #Task
    formRun.task(#taskRefresh);
    }
    }

    I tried this code.

  • GirishS Profile Picture
    27,827 Moderator on at

    Tell me one thing when you close FormC if it automatically navigates to FormA or you need to write the code in Close method to navigate to FormA?

    Thanks,

    Girish S.

  • Awaxx Profile Picture
    229 on at

    When i close form C i came back to form A

    Automatically

  • GirishS Profile Picture
    27,827 Moderator on at

    Okay then try the below suggestion.

    On the FormB init method get the caller of FormA. Below code will be on FormB.

    [Form]
    public class FormB extends FormRun
    {
        FormRun fRun;
        
        //override init method of form and get caller form run.
        public void init()
        {
            fRun = element.args().caller();
        }
        
        //now you need to call the FormC upon closing of FormB
        //override closeOk method of form.
        public void closeOk()
        {
            Args    args;
            FormRun formRun;
            super();
            //Call the form directly.
            args = new Args(formStr(rsmMake));
            //now pass FormA caller.
            args.caller(fRun);
            formRun = new FormRun(args);
            formRun.init();
            formRun.run();
            formRun.wait();
        }
    }
    

    Now on the FormC add the below code.

    [Form]
    public class FormC extends FormRun
    {
        FormRun  fRun;
        
        public void init()
        {
            fRun = element.args().caller(); // here u will get FormA caller
        }
        
        //now override the closeOk method of form.
        public void closeOk()
        {
            FormDataSource fds = fRun.dataSource("Mention the FormA table name");
            now call refresh and research method.
            fds.refresh();
            fds.reread();
            fds.research();
        }
    }

    If it's still not working debug the code and check.

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans