Skip to main content

Notifications

Announcements

No record found.

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

Refresh datas from form

(0) ShareShare
ReportReport
Posted on by 419

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.

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Refresh datas from form

    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.

  • Awaxx Profile Picture
    Awaxx 419 on at
    RE: Refresh datas from form

    When i close form C i came back to form A

    Automatically

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Refresh datas from form

    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
    Awaxx 419 on at
    RE: Refresh datas from form

    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.

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,613 Super User 2024 Season 1 on at
    RE: Refresh datas from form

    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.

  • GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Refresh datas from form

    Can you share your code?

    Thanks,

    Girish S.

  • Awaxx Profile Picture
    Awaxx 419 on at
    RE: Refresh datas from form

    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.

  • Suggested answer
    GirishS Profile Picture
    GirishS 27,832 Super User 2024 Season 1 on at
    RE: Refresh datas from form

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans