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

Notifications

Announcements

Community site session details

Community site session details

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

How to get the value of a control from the caller form where the control is not bound to a datasource

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

On the modified method of Field1, I want to first check the following:

  • The caller form is a specific form
  • The customer control on the current form is visible

    If that's the case, then I want to the value of the control from the caller form and assign it to the customer control in the current form  -- Note the control that I want to take it's value is not bound to a datasource

    how to do that?
    [FormControlEventHandler(formControlStr(CaseDetailCreate, Field1), FormControlEventType::Modified)]
    public static void CaseCategory_OnModified(FormControl sender, FormControlEventArgs e)
    {
        formRun callerFormNum = sender.formRun().args().caller();
        if(sender.formRun().args().callerName() == formstr(XXCustomerWorkspace) && XXcustomer.visible())
        {
            XXcustomer.Text(i want to get the value of the control that is not bound to a datasource from the caller form);
        }
    }

Also, I'm getting error on firstLine
Unable to cast object of type 'Dynamics.AX.Application.CaseDetailForm' to type 'Dynamics.AX.Application.FormRun'.'

I have the same question (0)
  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, You can try below code you find caller of the caller form

    FormRun callerFormRun = sender.formRun();
    FormRun origCallerFormRun = callerFormRun.args().caller();

    Regarding, accessing value of unbound form field, try accessing control from formRun.Design and accessing value of control.

     https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/398587/access-unbound-control-in-form-datasource-method-coc 

  • junior AX Profile Picture
    1,552 on at

    Hi Mohit,

    I can see that the caller In both cases is "CaseDetailForm" class

    But one is actually called from "CaseDetail"  form

    and one is called from XXCustomerWorkspace

    So maybe i need to get the caller of the caller in this case to know if it's coming from standard form CaseDetail or my new customized form XXCustomerWorkspace?  if yes how to do that?

    Also the other part of the question:

    i want to get the value of the control that is not bound to a datasource from the caller form

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, In the first line, issue is that you have already mapped FormRun object with caller. Here caller is CaseDetailForm which is a class, not a Form. That's why system is throwing unable to cast object error.

    First check if caller is a form, check this article

    kiwiaxguy.blogspot.com/.../checking-to-see-if-caller-is-form.html

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

News and Announcements

Season of Giving Solutions is Here!

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
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 338 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans