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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Best way to access a formControl (from FormRun or FormDesign) and possible pros and cons

(1) ShareShare
ReportReport
Posted on by 14
Hi to all,
 
while browsing and looking for solutions to other problems, I noticed that there is no consensus or a general rule for how to access a formControl on a form.
I have seen solutions like the followings, all basically achieving the same:
 
FormControl  frControl;
FormControl  fdControl;
 
FormRun        fr           = this.formRun();
FormDesign   fd          = this.formRun().design();
str                  cName  = formControlStr(MyForm, MyControl);
 
frControl  = fr.control(fr.controlId(cName));
fdControl = fd.controlName(cName);
 
(Sorry, code looks ugly, but I don't understand how to make it work, markup language or other or mixed font usage do not work...) 
What I wrote above might not be 100% syntax correct, depending if we are trying to get a control from a Handler, in a form extension or other, but the point is:
 
You can access a control on the form both from the FormRun or FormDesign class.
So here my question: is there a preferred solution? If so why?
And if there is not a clear preference, what are possible pros and cons of the two approaches, when making the choice?
 
I remember something like a form can have multiple designs so accessing through the FormDesign is not 100% safe, but I am not sure if it is something I read or just a false memory. I cannot find anything that helps me sort this doubt.
Thanks to all!
 
I have the same question (0)

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 814 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 622

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans