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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

How to access a variable inside a form in event handlers?

(0) ShareShare
ReportReport
Posted on by 1,552

Hi,

I want to be able to get CaseDetailForm inside the event handler But I'm getting formRun doesn't contain this field

[Form]
public class CaseDetailCreate extends FormRun
{
    CaseDetailForm caseDetailForm;
}

    [FormControlEventHandler(formControlStr(CaseDetailCreate, OK), FormControlEventType::Clicked)]
    public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
    {
            FormRun formRun = sender.formRun();
            CaseDetailForm c = formRun.CaseDetailForm;
    }

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

    Hi check this article

    https://wp.me/p76m04-fx

    Is CaseDetailForm a form control?

  • Suggested answer
    Martin Dráb Profile Picture
    238,736 Most Valuable Professional on at

    You made thing more complicated than necessary by using an event handler instead of an extension. If you, for example, extend close() method of the form, you can refer to the variable simply by its name.

  • Suggested answer
    GirishS Profile Picture
    27,833 Moderator on at

    Hi,

    As Martin mentioned you can go for extension.

    But to solve this issue you can create one parm method and return "caseDetailsForm" buffer.

    You can later call that method using form Run.

    [Extensionof(formStr(FormName))]
    final class className
    {
        public CaseDetailsForm getCaseDetail()
        {
            return caseDetailForm;
        }
    }

     [FormControlEventHandler(formControlStr(CaseDetailCreate, OK), FormControlEventType::Clicked)]
        public static void OK_OnClicked(FormControl sender, FormControlEventArgs e)
        {
                FormRun formRun = sender.formRun();
                CaseDetailForm c = formRun.getCaseDetail();
        }

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 577 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 309

#3
Diego Mancassola Profile Picture

Diego Mancassola 259

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans