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 CRM (Archived)
Answered

Color Field with Javascript

(0) ShareShare
ReportReport
Posted on by 694

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

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    it's not a supported customization

  • Suggested answer
    Abed Haniyah Profile Picture
    4,287 on at

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

  • Daniel at VNS Profile Picture
    on at

    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.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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";

  • Suggested answer
    Daniel at VNS Profile Picture
    on at

    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

  • AnkitSinghal Profile Picture
    256 on at

    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.

  • Shahbaaz Ansari Profile Picture
    6,211 on at

    Hi Ricardo

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

    Thanks,

    Shahbaaz

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

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans