Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

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

Posted on by 8
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!
 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans