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 get formcontrol name of another form at DS event level.

(0) ShareShare
ReportReport
Posted on by

Hi experts.

Scenario while being at FormDatasrouceEventType::Query execution event of DS1 of Form A there is a need to get name of formControls for Form X.

Have written below code , but keep getting object reference not set for line #7 & 8 on RUNTIME , please suggest a fix.

[FormDataSourceEventHandler(formDataSourceStr(FORMA, DS1), FormDataSourceEventType::QueryExecuting)]
    public static void DS1_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e)
    {
        FormRun         formRun             =   sender.formRun();
        FormRun         callerFormRun;
        FormControlName callerFrmCtrlName   =   formRun.args().callerFormControl().name();
        FormControlName failTileCtrlName    =   callerFormRun.design().controlName(formControlStr(FormX,Fail)).name();
        FormControlName passTileCtrlName    =   callerFormRun.design().controlName(formControlStr(FormX,Pass)).name();

        if(callerFrmCtrlName == FailTileCtrlName)
        {
            //do something
        }
        else if(callerFrmCtrlName == passTileCtrlName)
        {
           //do something
        }

    }

Thanks

Mav

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

    It means that you're trying to call a method on a variable that doesn't contain any actual object. Its value is null.

    In your case, you're trying to call design() method on callerFormRun, but you've never assigned any value to it. Asking for design of no form makes no sense, therefore you get an error.

    The name suggests that you wanted to assign the name of the caller form: callerFormRun = formRun.args().caller().

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 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans