locked
Field label formatting [CRM 2011] [Jscript] RRS feed

Answers

  • The thing is that these methods weren't really supported in 4.0 and that has carried forward to 2011. As such, Microsoft didn't build that functionality into the Xrm.Page object model this time around.

    Jason Lattimer

    Thursday, August 30, 2012 2:27 AM
    Moderator
  • A supported option could be to use single row html web resources to show the label in whatever style/colour you like and set the data fields to be immediately next to them with their 'show label' property set to do not show. Here's a blog of how to add text blocks so you could adapt it.

    Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd Microsoft Community Contributor Award 2011

    Monday, November 5, 2012 10:19 PM
    Answerer

All replies

  • The thing is that these methods weren't really supported in 4.0 and that has carried forward to 2011. As such, Microsoft didn't build that functionality into the Xrm.Page object model this time around.

    Jason Lattimer

    Thursday, August 30, 2012 2:27 AM
    Moderator
  • Thursday, August 30, 2012 4:41 AM
  • So, if it I use those 4.0 code snippets, what is the likelihood that cross-browser functionality (when it's rolled out) will cause that to bomb?
    Thursday, August 30, 2012 4:18 PM
  • It is certainly a possibility - since that code isn't supported it wasn't really addressed in the breaking script changes. You are very likely to see this code break in the next version of CRM after 2011 as crmForm is currently depricated.

    Resolve Breaking Script Issues When Upgrading Microsoft Dynamics CRM


    Jason Lattimer

    Thursday, August 30, 2012 4:28 PM
    Moderator
  • Followings are the style that I created for disabled fields, according to the style guide in SDK:

    var disabledField = Xrm.Page.getAttribute(field);
    document.getElementById(disabledField).style.border = "#c4c8ce 1px solid";
    document.getElementById(disabledField).style.color = "#838383";      
    document.getElementById(disabledField).style.backgroundColor = "transparent";

    I also tried the following scripts:
    document.getElementById(disabledField).style.fontsize = "12px";
    document.getElementById(disabledField).style.borderColor = "";

    I don't think the .style.fontweight works if I remember it right. And hopefully these are good enough for the style/format that you want to achieve.

    Thursday, August 30, 2012 4:49 PM
  • Hi, Try this from your Sample:

            document.getElementById("new_button").style.backgroundColor = 'red'; 

            document.getElementById("new_button").style.Color = 'black';

            document.getElementById("new_button").style.borderColor = 'red';

            document.getElementById("new_button").style.fontweight = 'bold';


    Naren


    • Edited by Naren MN Friday, August 31, 2012 11:27 AM
    Friday, August 31, 2012 11:26 AM
  • I loaded the Custom Code Validation Tool (http://www.microsoft.com/en-us/download/details.aspx?id=30151); according to the tool's Read Me file, getElementById is one of the things that could cause issues.

    "... the elements that the tool is looking for to assist with validating whether the custom JavaScript and HTML web resources will work with other web browsers such as Chrome, FireFox, and Safari.  Some of the elements are simply references to Microsoft technologies, such as ActiveXObject, which are not supported in other browsers.  Others are references to the Document Object Model, which may have changed as part of the June 2012 Service Update so customers and partners will want to investigate whether these references are still valid."

    This is me investigating. :)

    Friday, August 31, 2012 2:09 PM
  • A supported option could be to use single row html web resources to show the label in whatever style/colour you like and set the data fields to be immediately next to them with their 'show label' property set to do not show. Here's a blog of how to add text blocks so you could adapt it.

    Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd Microsoft Community Contributor Award 2011

    Monday, November 5, 2012 10:19 PM
    Answerer
  • Hello Linhardt,

    We can format the fields in by getting those ids from developer tools(f12) and then use javascript coding document.getElementbyId 

    document.getElementById("name").style.backgroundColor="red";// here name defines the text in the field "name".
    document.getElementById("name_c").style.backgroundColor="aqua";//here name_c defines the label of field "name"
    document.getElementById("name_d").style.backgroundColor="yellow";//here name_d defines the border of field "name" 
    document.getElementById("name").style.color="yellow";

    (mark as answer and vote as helpful) if my reply works for u.

    Thanks,

    SASANK K

    Tuesday, November 6, 2012 4:24 AM