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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to Get Control Name on the Form for JavaScript to Use in formContext.getControl(arg) Client API

(0) ShareShare
ReportReport
Posted on by 3,407

The new modern form editor is not giving the control names the same as the schema name of the field when you place the fields on the form using the new modern WYSIWYG form editor.
It generates the control names such as "Single-line_text_1" which does not make sense for the developers to reference with the actual field.

That makes it harder for us to find the control name and use in formContext.getControl("new_fieldname") for Control Client APIs suchs as (setVisible, setLabel, etc.)

How do you normally get the control name if repeated controls are presented on the form with _2, _3 or controls placed with modern form editor such as "Single-line_text_1"?
Browser DevTools (F12) or any other tool?

What is the best approach to get Control Control Client APIs for the fields placed on the form using modern form editor?

This is the best way I can think of but is there any better way?

formContext.getAttribute("new_fieldname").controls.forEach(function (control, index) { control.setVisible(false); });

Or we should not use the modern form editor to place the fields at all until the issue is resolved?

I have the same question (0)
  • cloflyMao Profile Picture
    25,210 on at

    Hi Linn Zaw Win,

    You could install a extension called "Level up for Dynamics CRM/365" if your browser is Chrome,

    https://chrome.google.com/webstore/detail/level-up-for-dynamics-crm/bjnkkhimoaclnddigpphpgkfgeggokam?hl=en

    https://github.com/rajyraman/Levelup-for-Dynamics-CRM

    it'll show all tabs, sections and fields shcema name by clicking a button, which could help you locate these elements quickly.

    pastedimage1572837569455v2.png

    Regards,

    Clofly

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    I guess the best way i what you have mentioned. As MS can change the name style in future, this is the safest way.

    formContext.getAttribute("new_fieldname").controls.forEach(function (control, index) { control.setVisible(false); });

    Hope this helps.

  • Linn Zaw Win Profile Picture
    3,407 on at

    Hi @cloflyMao

    Thanks for your response.

    What I am actually looking for is a way to get the attribute Control name (not attribute schema name) which can be different

    - if you add multiple controls of the same field to the form (which is postfix with _2, _3, etc. when you add from the classic form editor)

    - if you add the field onto the form using the modern form editor which generates the control names such as "Single-line_text_1"

    I did't see any option to show "Control names" in the "Level up for Dynamics CRM/365" extension.

    Maybe I will try to submit a pull request when I have some spare time.

  • cloflyMao Profile Picture
    25,210 on at

    Hi Linn,

    Sorry for misunderstanding,

    I thought that your code that getting all controls by field's attribute/schema name would be the best method at present.

    Regards,

    Clofly

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans