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 :
Microsoft Dynamics CRM (Archived)

Javascript styleguide to access fields

(0) ShareShare
ReportReport
Posted on by

Have you had any pattern to access fields in:

  • Single instance (org_sourcetype)
  • Multiple instances (org_sourcetype1, org_sourcetype2)

Of course, we can hard code when using getControl('org_sourcetype1') but it's lacking the knowledge of the field.

How about if we start a Json definition related to UI Form

var UI = {
     HEADER: {
         TYPE: 'header_type'
     },
     DETAIL: {
         DEPARTMENT: 'department',
         SOURCE_TYPE: 'sourcetype'
     },
     SUMMARY: {
         DEPARTMENT: 'department1',
         SOURCE_TYPE: 'sourcetype1'
     }        
};

// Access
formContext.getControl(UI.HEADER.TYPE) or formContext.getControl(UI.SUMMARY.SOURCE_TYPE)

PROS:

  • Easy to indicate fields in case multiple instances
  • Readable and maintainable

CONS:

  • Changing UI, need to update the JSON to reflect changes, still, need to touch Javascript file.

Any ideas about this?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Flydancer Profile Picture
    1,332 on at

    I am using the following tool to automatically generate Form specific "intellisense" it works with JS & TS xrmtoolkit.com/.../ScriptingIntellisense

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans