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, ...
Answered

how to research other form datasource

(0) ShareShare
ReportReport
Posted on by

Hi experts,

In my controller class i have helper method like below which works fine for my 1st form, however i also need to refresh my 2nd form, so can you please help in filling the incomplete code below.

private void refreshCallingForm(args _args)
    {
        str            fname;
        FormDataSource fds;

        fname   = _args.callerName();
        info("fname is " fname);
        if(_args && _args.record() && FormDataUtil::isFormDataSource(_args.record()))  
        {
            fds = FormDataUtil::getFormDataSource(_args.record());   
            fds.research(true);
           
        }

        if (fname != formStr(SalesTableListPage))
        {
            //fds = //SalesTable DS of SalesTableListPage
            fds.research();
        }
       

I have the same question (0)
  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    How will you decide which data source to research, if it's not the data source of _args.record()?

  • Mav Profile Picture
    on at

    Yep, you are correct  .  Need to have line for that & then choose salestable datasource, any idea on how to get that done.

    Thanks

    Mav

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    What is answer to my question? That it has no relation to the data source of  _args.record() and you need to hard-code it in some way? If so, in which way?

    For example, what about taking the primary data source of the caller form?

  • Mav Profile Picture
    on at

    fds = _args.caller().dataSource(0) would get get the primary data source of caller form i guess.

    Can you tell me how do i get to research the fds of different form with same datasource (salestablelistpage, salestable n this case)

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Sorry, I'm not sure what you mean.

    Do you want to hard-code a data source name (SalesTable) and try to find it in the caller form?

    It would help if you forget code and data source names for a moment and explained what you're doing in GUI and what you want to happen.

  • Mav Profile Picture
    on at

    User  launches a dialog at form B and provide inputs .

    Form B gets researched with above code & shows updated data -- this is working fine

    User closes form B and now returns to Form A

    Form A is not researched & still shows old data.

    The ds of form B which was researched and shows updated value in form B  is the same ds of formA.

    How do we research this DS  of form A so that user sees updated data on Form A also.

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    It seems that your steps should start in Form A, shouldn't they?

    First ask yourself when the reserch should happen.

    Then how you will decide which data source, or data sources, you want to research. This is what I tried to lead you to above. Notice that I've made a suggestion (researching the primary data source) - that's one of several option that you can consider.

    I can't give you any more specific advise, but your description is way to general and doesn't allow to infer your requirements.

  • Mav Profile Picture
    on at

    Can you share how to research the primary data source /salestable  of form A in above code ?

  • Martin Dráb Profile Picture
    237,878 Most Valuable Professional on at

    Does Form A pass a record to Form B? If so, you can use exactly the same approach you used for Form B. Unfortunately you didn't explained the relation and you gave us made-up names Form A and Form  B instead of your actual business scenario, which forces us to guessing and considering options that may be irrelevant for you (and maybe missing the ones you actually need). It's not very efficient use of scarce resources.

    Another option is what you can find by simply looking into documentation (How to: Refresh the Calling Form):

    #Task
    FormRun formRun = element.args().caller() as FormRun;
    
    if(formRun)
    {
        formRun.task(#taskF5);
    }

    There are plenty of other appraches useful in certain situations, each with its own pros and cons. For example, you can get a list of root data sources (FormRun.rootFormDataSources()) and research the first one, or all of them). Or you can get a specific datasource by calling datasource() (by index, by name or without any parameter). Or you can get the first data source for a certain table by calling SysFormDataSource::findDataSource(). And so on...

  • Mav Profile Picture
    on at

    Yes form A pass a record to form B

    I mentioned Form A is salestablelistpage and Form b is salestablepage.

    The same approach does work when i call the dialog from form A however requirement is that even when dialog is called from form B the above code should be modified in a way that it does research form A in addition to form B.

    The datasource of formA and Form b is common , salesTable.

    I cannot use the element,args in above code as element is out of context of controller class.

    I need to know how to refresh /reread parent form data source salestable which may or may not be the primary datasource.

    List of root datsources will be bind to formrun , formrun will have formb and we need to refresh form A's salestable and not form B.

    Please suggest a fix using which form A gets refreshed/researched(incase refresh does not work) immeditaely after form b is researched in above code.

    Flow

    User selects record in salestablelistpage --> clicks the record --> salestableform is opened -->launches dialog --> returns to salestableform from dialog prompt after clicking Ok on dialog -->salestableform gets researched and updated values are seen  ALL GOOD UNTIL HERE

    Now user closes salestableform and lands back on salestablelistpageform and here the updated values cannot be seen till user manually refresh the page. THIS IS what needs to be done AUtomatically via the code.

    Let me know if you still need anything more.

    Just need to know  how to refresh /reread parent form (salestablelistage) data source salestable (which may or may not be the primary datasource ) in controller class after controller class is done refreshing/rereading the child form (salestable) as shown in code above.

    Thanks

    Mav

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 646 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