Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)
Answered

Color Field with Javascript

Posted on by 690

Good afternoon,

I would like to color a label of a field in the crm 2016 On Line

Document.getElementById ("field_c"). Style.backgroundColor = 'red';

But it's giving the style can not be supported.

Can anyone tell me if it is possible to color the label in CRM 2016 OnLine with Java Script?

Tank You.

*This post is locked for comments

  • Shahbaaz Ansari Profile Picture
    Shahbaaz Ansari 6,203 on at
    RE: Color Field with Javascript

    Hi Ricardo

    please check this post this might help you community.dynamics.com/.../201427

    Thanks,

    Shahbaaz

  • AnkitSinghal Profile Picture
    AnkitSinghal 256 on at
    RE: Color Field with Javascript

    try this code

    function ChangeBackgroundTextBox()

    {

    var job=   Xrm.Page.data.entity.attributes.get(fieldname).getValue();

    var result= job.fontcolor("green");

    document.getElementById(fieldname).innerHTML = result;

    }

    Please mark my answer.

  • Suggested answer
    RE: Color Field with Javascript

    More details Ricardo.  CRM 2015 introduced the new form rendering engine for better performance but a byproduct was that now no text or page color customizations are supported.  Have to wait for MS to add this to supported functionality or use legacy rendering engine which is much slower.  See for details:

    blogs.msdn.microsoft.com/.../microsoft-dynamics-crm-online-2015-update-1-new-form-rendering-engine

    stackoverflow.com/.../change-the-colour-of-text-field-in-dynamics-crm-2016

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Color Field with Javascript

    Ricardo,

    It's not supported (and I will not recommend to use that approach) but you can try following:

    window.parent.document.getElementById("field_c").style.backgroundColor = "red";

  • RE: Color Field with Javascript

    These might help you Ricardo.

    http://burnignorance.com/ms-crm-app-development-tips/using-java-script-change-background-color-of-fields-on-form-in-crm-2011/

    https://dynamicsofdynamicscrm.com/2014/05/06/change-color-for-text-fields-dynamics-crm-2013/

    http://www.crmbuzz.co/how-to-update-crm2015-form-field-background-color/

    I'd thought getElementById was not supported, per MS in the SDK but they also show examples using it:

    For most script development work outside of Microsoft Dynamics 365, developers may be accustomed to referring to page elements by using the document.getElementById method. For Microsoft Dynamics 365 form scripts this method is not supported. It is important to recognize that the attribute stores the data and the control is simply the presentation of the attribute in the form. For controls bound to attributes you may need to adjust the way you are accustomed to accessing data in the form.

  • Suggested answer
    Abed Haniyah Profile Picture
    Abed Haniyah 4,285 on at
    RE: Color Field with Javascript

    Unfortunately there is no OOB or supported way to color labels on Dynamics CRM

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Color Field with Javascript

    it's not a supported customization

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans