Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Javascript: Changing the labels on account form (works on account name, but not other field)

Posted on by Microsoft Employee

If this works:

Xrm.Page.getControl(name').setLabel('Postal Code') = 'x';

Then why do these all fail:

Xrm.Page.getControl('address1_postalcode').setLabel('Postal Code') = 'x';
Xrm.Page.getControl('address1_stateorprovince').setLabel('Province') = 'x';
Xrm.Page.getControl('address2_postalcode').setLabel('Postal Code') = 'x';
Xrm.Page.getControl('address2_stateorprovince').setLabel('Province') = 'x';
Xrm.Page.getControl('customfield').setLabel = 'x';

('Postal Code);
Xrm.Page.getControl

Please suggest a workaround.  Thanks.

*This post is locked for comments

  • Shidin Haridas Profile Picture
    Shidin Haridas 3,497 on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    Wendy,

    The HTML would not render if you are using the above mentioned method of setting the label.

    One workaround would be to do a direct DOM manipulation, such as document.getElementById('yourControlName'), but that would be unsupported customization & not recommended.

  • windyMill Profile Picture
    windyMill 435 on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    Can we set html string  in the label ?

  • Verified answer
    Mahadeo Matre Profile Picture
    Mahadeo Matre 17,021 on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    Hi,

    Instead of changing label using JavaScript.. you can change label from Form customization.. so that all places you will see same label.

    All places means, all forms, views, sub grids etc. otherwise you need to change it all the places either by using supported Javascript or unsupported JavaScript.

    even if you needed.. you need can change label like

    Xrm.Page.getControl('address1_postalcode').setLabel('Postal Code');

    Here are more details on form scripting

    msdn.microsoft.com/.../gg334266.aspx

    msdn.microsoft.com/.../jj602964.aspx

    msdn.microsoft.com/.../gg328474.aspx

    Hope this will help..

    Thanks,

  • Verified answer
    PS Profile Picture
    PS 23,577 on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    But why do you need a Javascript to change the label on form.

    It can be done from the form itself

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    You're right about that I made this email in haste.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Javascript: Changing the labels on account form (works on account name, but not other field)

    by the way I did not mess a  ' character in production.  cannot edit post.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans